Title: Using the WP get_option() function
Last modified: August 19, 2016

---

# Using the WP get_option() function

 *  [holliday22](https://wordpress.org/support/users/holliday22/)
 * (@holliday22)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/using-the-wp-get_option-function/)
 * So how do you use WordPress’s variable get_option() function to set a variable?
 * I tried:
 * $variable=get_option(‘option’);
 * But I had no luck. Got an error message as “Call to undefined function.”
 * I tried including /wp-includes/functions.php but it made no difference.
 * Anyone got any idea? Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [holliday22](https://wordpress.org/support/users/holliday22/)
 * (@holliday22)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/using-the-wp-get_option-function/#post-1985576)
 * I figured it out. I wasn’t including /wp-includes/functions.php in the file where
   the function was located.
 * When I figured that out, I got another error: Fatal error: Call to a member function
   main() on a non-object
 * It took me 2 hours to figure that one out. The problem was something like this:
 * I was including functions.php in example.php and then including example.php in
   options_menu.php. So in options_menu.php, the include statement was in the body
   section of the page which cause the error.
 * Long story short, include the functions file **within the necessary function**
   rather than at the file level!
 *  [GRAQ](https://wordpress.org/support/users/graq/)
 * (@graq)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/using-the-wp-get_option-function/#post-1985673)
 * Usually (for theme development) your functions are put _in_ functions.php – that
   is what it is there for.
 *  Thread Starter [holliday22](https://wordpress.org/support/users/holliday22/)
 * (@holliday22)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/using-the-wp-get_option-function/#post-1985681)
 * I’m working on a plugin, FWIW.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Using the WP get_option() function’ is closed to new replies.

## Tags

 * [Call to undefined function:](https://wordpress.org/support/topic-tag/call-to-undefined-function/)
 * [Get_Option](https://wordpress.org/support/topic-tag/get_option/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 3 replies
 * 2 participants
 * Last reply from: [holliday22](https://wordpress.org/support/users/holliday22/)
 * Last activity: [15 years, 2 months ago](https://wordpress.org/support/topic/using-the-wp-get_option-function/#post-1985681)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
