Title: adding echo get_option correctly
Last modified: August 20, 2016

---

# adding echo get_option correctly

 *  [HorrorUK](https://wordpress.org/support/users/horroruk/)
 * (@horroruk)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/adding-echo-get_option-correctly/)
 * I have the following code, but I need to add a line of code from the WP admin
   to this, but can’t figure out how to do that.
 * I started off with this:
 *     ```
       <?php
       $app_id = "echo get_option('appid');";
       ?>
       ```
   
 * Then I tried to add the line of code from admin using:
 *     ```
       $app_id = "echo get_option('appid');";
       ```
   
 * A bit too literal maybe, so I removed the semi-colon within the quotes:
 *     ```
       $app_id = "echo get_option('appid')";
       ```
   
 * I’m running out of hair to pull out, so if anybody can help, that would be great.
 * Thanks.

Viewing 15 replies - 1 through 15 (of 23 total)

1 [2](https://wordpress.org/support/topic/adding-echo-get_option-correctly/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/adding-echo-get_option-correctly/page/2/?output_format=md)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/adding-echo-get_option-correctly/#post-2558555)
 * Try:
 *     ```
       <?php
       $app_id = get_option('appid');
       echo $app_id;
       ?>
       ```
   
 *  Thread Starter [HorrorUK](https://wordpress.org/support/users/horroruk/)
 * (@horroruk)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/adding-echo-get_option-correctly/#post-2558557)
 * Thanks, I’ll give that a go 🙂
 *  Thread Starter [HorrorUK](https://wordpress.org/support/users/horroruk/)
 * (@horroruk)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/adding-echo-get_option-correctly/#post-2558562)
 * I wrote that slightly wrong in the first box.
 * It should be reading something like (it’s Facebook):
 *     ```
       <?php
       $app_id = "76543768778578";
       ?>
       ```
   
 * I tried:
 *     ```
       <?php
       $app_id = get_option('appid');
       echo $app_id;
       ?>
       ```
   
 * But it still doesn’t seem to be accepting it.
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/adding-echo-get_option-correctly/#post-2558566)
 * Did you store that app_id as an option first?
 *  Thread Starter [HorrorUK](https://wordpress.org/support/users/horroruk/)
 * (@horroruk)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/adding-echo-get_option-correctly/#post-2558568)
 * Bit of a blonde moment going on today, sorry.
 * How do you store the app_id option?
 *  Thread Starter [HorrorUK](https://wordpress.org/support/users/horroruk/)
 * (@horroruk)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/adding-echo-get_option-correctly/#post-2558569)
 * I’m starting to think I’ve totally messed up here. Looking at the page, I’ve 
   not actually called in any page that holds the info or the db.
 * I’m wondering if I need to add a line calling the database into the page?
 *  Thread Starter [HorrorUK](https://wordpress.org/support/users/horroruk/)
 * (@horroruk)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/adding-echo-get_option-correctly/#post-2558575)
 * I don’t know if this will help make sense of it:
 * [http://pastebin.com/qQe8kfVY](http://pastebin.com/qQe8kfVY)
 * This is the page I have, and it is the second block of PHP I’m trying to work
   on to bring in the two bits of info I added to admin.
 * Please note, I changed the two bits of info names, to make it simpler.
    They 
   are now:
 * tabsappid
    tabsappsecret
 * This is the error I receive:
 * Parse error: syntax error, unexpected T_STRING in /var/www/vhosts/writers-site.
   com/httpdocs/wp-content/plugins/facebook-tabs-for-wordpress/fbindex.php on line
   7
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/adding-echo-get_option-correctly/#post-2558577)
 * Why not just use:
 *     ```
       $facebook = new Facebook(array(
               'appId' => '76543768778578',
               'secret' => $app_secret,
               'cookie' => true
       ));
       ```
   
 *  Thread Starter [HorrorUK](https://wordpress.org/support/users/horroruk/)
 * (@horroruk)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/adding-echo-get_option-correctly/#post-2558591)
 * I was thinking about something like that, so I tried:
 *     ```
       <?php
       $app_id = get_option('tabsappid');
       echo $app_id;
       $app_id = get_option('tabsappsecret');
       echo $app_id;
   
       $facebook = new Facebook(array(
               'appId' => $app_id,
               'secret' => $app_secret,
               'cookie' => true
       ));
       ?>
       ```
   
 * However, that causes the following error:
 * > Fatal error: Call to undefined function get_option() in /var/www/vhosts/writers-
   > site.com/httpdocs/wp-content/plugins/facebook-tabs-for-wordpress/fbindex.php
   > on line 6
 * It looks like it doesn’t realise it’s part of WordPress.
 * It makes it worse feeling so close to the answer.
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/adding-echo-get_option-correctly/#post-2558593)
 * Why are you trying to use get_option() when this hasn’t been stored in the database
   as an option?
 *  Thread Starter [HorrorUK](https://wordpress.org/support/users/horroruk/)
 * (@horroruk)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/adding-echo-get_option-correctly/#post-2558677)
 * In my WordPress admin I’ve set up a page to take two values which are stored 
   as _tabsappid_ and _tabsappsecret_, and then I’m trying to get those values to
   to show in the correct sections on this page.
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/adding-echo-get_option-correctly/#post-2558777)
 * Have you confirmed that these values are being stored in the database correctly?
 *  Thread Starter [HorrorUK](https://wordpress.org/support/users/horroruk/)
 * (@horroruk)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/adding-echo-get_option-correctly/#post-2558784)
 * Hi Esmi, thanks for sticking with me on this one.
 * I just checked the database, and it is storing the values ok.
 *  Thread Starter [HorrorUK](https://wordpress.org/support/users/horroruk/)
 * (@horroruk)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/adding-echo-get_option-correctly/#post-2558785)
 * I think I must be missing calling wordpress in somehow, because of the part of
   the error message that says:
 *     ```
       Fatal error: Call to undefined function get_option()
       ```
   
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/adding-echo-get_option-correctly/#post-2558786)
 * > In my WordPress admin I’ve set up a page to take two values which are stored
   > as tabsappid and tabsappsecret
 * Is this a theme options page? If so, have you seen [http://www.chipbennett.net/2011/02/17/incorporating-the-settings-api-in-wordpress-themes/](http://www.chipbennett.net/2011/02/17/incorporating-the-settings-api-in-wordpress-themes/)
   Or [http://ottodestruct.com/blog/2009/wordpress-settings-api-tutorial/](http://ottodestruct.com/blog/2009/wordpress-settings-api-tutorial/)
 * Can you see these options in clear text when you view [http://your_domain/wp-admin/options.php](http://your_domain/wp-admin/options.php)?
   Or are they serialized arrays?

Viewing 15 replies - 1 through 15 (of 23 total)

1 [2](https://wordpress.org/support/topic/adding-echo-get_option-correctly/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/adding-echo-get_option-correctly/page/2/?output_format=md)

The topic ‘adding echo get_option correctly’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 23 replies
 * 2 participants
 * Last reply from: [esmi](https://wordpress.org/support/users/esmi/)
 * Last activity: [14 years, 4 months ago](https://wordpress.org/support/topic/adding-echo-get_option-correctly/page/2/#post-2558844)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
