• 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

    (@holliday22)

    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!

    Usually (for theme development) your functions are put in functions.php – that is what it is there for.

    Thread Starter holliday22

    (@holliday22)

    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.