ThemeShaper Forums » Thematic


Using PHP to echo option

(5 posts)
  • Started 7 years ago by proto
  • Latest reply from helgatheviking
  • This topic is not resolved
  1. proto

    Hello All,

    I'm already using <?php echo "something here" ?> to style a few elements within my child theme options, it's working fine. I'm having a little trouble echoing a user input for social media links within my child theme options. The idea being the web user enters their full social media link URL and the link assumes that link destination. Here's the my code from my "functions.php" file hard coded including the crucial <?php echo "something" > option:

    <div id="fb" class="sociallinks"><a href="<?php echo
    $pixelwoo_facebookurl ?>" target="_blank" >
    <img src="locationofimagefiles/2012/01/facebook.jpg" width="16"
    height="16" alt="facebook" /></a><span class="socialtext">Facebook
    </span></div><!-- End of fb -->

    Here's my child option array code contained in separate - library/newfolder:

    array( "name" => __('Facebook URL','thematic'),
               "desc" => __('Add your full facebook URL, eg http://www.','thematic'),
               "id" => "pixelwoo_facebookurl",
               "std" => "",
               "type" => "text"

    Finally here's the options being echoed:

    //Options for facebook URL
    	  case 'text':
          <tr valign="top">
            <th scope="row"><?php echo $value['name']; ?>:</th>
              <input name="<?php echo $value['id']; ?>" id="
    <?php echo $value['id']; ?>" type="text" value="
    <?php echo stripslashes(get_option( $value['id'], $value['std'] )); ?>" />
              <?php echo $value['desc']; ?>

    Any thoughts where I'm going wrong? When I click on the my facebook icon it acts as a link (mouse cursor changes to link on hover) but when clicked it's simply blank?

    Thanks in advance folks!

    Posted 7 years ago #
  2. how are you saving the options? are they defo in the database? i am a fan of devin's options framework.

    <?php echo
    $pixelwoo_facebookurl ?>

    where are you defining this variable?

    Posted 7 years ago #
  3. proto

    Hey Helga,

    So, I thought the variable was being defined here:

    "id" => "pixelwoo_facebookurl",

    But I'm not sure it is. Strangely, with my other options (they all live in the options file or options styling file they work fine). I was hoping someone might see where I'm going wrong, as the other child theme options I have (coded the same) work. The only difference is that I'm trying to call the variable in my "functions.php" file.

    If anyone can see what I'm missing I'm much obliged! :)

    Posted 7 years ago #
  4. You need to be setting the value of $pixelwoo_facebookurl from your options array that is stored in the wp-options table in the database. Look at:get_option()

    It would also be very wise to make sure that you're setting the appropriate the user capabilities for accessing the theme options form and validating the user submitted data before storing into in the database.

    Look here:
    Settings API
    Themashaper Settings API Tutorial

    If this is all greek to you there are options plugins out there you could employ:
    Devin's Options Framework

    Helga The Viking did a fork of that Plugin for Thematic I think might speed up integration with Thematic.
    The Helga Fork

    Posted 7 years ago #
  5. @proto - nopers. that doesn't define the variable INSIDE your new function or do anything to retrieve it from the DB. $pixelwoo_facebookurl it isn't a global variable.

    my fork is pretty much dead, and i would advise using devin's options framework instead.

    Posted 7 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.