Forums

get_option multiple calls (3 posts)

  1. ext103
    Member
    Posted 1 year ago #

    hello everyone, just a quickie.

    i have a <ul> of bookmarking icons on my new theme. when clicked they all use a function i created to get post short url

    here it is
    function ext_theme_short_url(){global $post; echo get_bloginfo('url')."/?p=".$post->ID;}

    now, should i add this to each href for each icon? like this
    <?php echo ext_theme_short_url(); ?>

    or should i call it like this?

    $link = echo ext_theme_short_url();

    and then add
    <?php echo $link; ?>

    to each href.

    i guess what i am asking is will this reduce the mysql lookup from many requests to 1?

  2. MichaelH
    Volunteer
    Posted 1 year ago #

    If I understand it correctly, since get_bloginfo('url'); 'eventually' uses get_option, and the site_url and home values are autoloaded, I'd guess there's only one read of the database and that's done automatically by WordPress core.

  3. ext103
    Member
    Posted 1 year ago #

    is that right?

    i mean when you call an option, does it only call it once per page?

    say i had get_bloginfo('url'); called 5-6 times on the same page.

    would that give me 5-6 database calls or one?

    thanks for posting

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags