• Resolved latro666

    (@latro666)


    Got a value in the options table, lets say blogname.
    <?php echo get_option('blogname'); ?>

    Works fine within the main loop in say page.php, however using it outside the loop say in a sidebar results in the output of:

    `Recent Posts
    Hello world!
    Recent Comments
    Mr WordPress on Hello world!
    Archives
    January 2012
    Categories
    Uncategorized
    Meta
    Site Admin
    Log out
    Entries RSS
    Comments RSS
    www.remarpro.com’

    Is it possible without resorting to a normal php mysql query to use this function outside of the loop? It seems weird that it’s loop specific as I cant see a reason you’d need to know what post ID you are on to access the options table as its global.

    :s

Viewing 3 replies - 1 through 3 (of 3 total)
  • I’m 99.9% sure that <?php echo get_option('blogname'); ?> etc has always worked me outside the Loop. If it’s not working for you, then I’d suggest that there’s something funky going on in your theme.

    Thread Starter latro666

    (@latro666)

    You are right! omg one of those days:

    <?php
    if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar(‘normal panel’) ) :
    ?>
    <?php endif; ?>

    Was calling the DEFAULT wordpress sidebar widgets you get on install, it was outputting fine further down the page!

    time to go home and eat something i think. Thanks for the jolt ??

    No problem ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘get_option() from outside the loop?’ is closed to new replies.