Support » Networking WordPress » Why does bloginfo() echo to screen?

  • Resolved kirkward


    I am trying to get the ID of a particular post that is replicated onto various blogsites in a network.

    The code below works to give me the blog ID, but, the blog URL is shown onscreen. What do I need to change?

    I have been unable to get it to work without including the blog URL from bloginfo.

    // *********** Begin
    $target_post_ID = url_to_postid(bloginfo('url') . '/category-slug/post-slug/');
    // *********** End
Viewing 4 replies - 1 through 4 (of 4 total)
  • I presume you are pointing out that the ‘display’ parameter means it will print to the screen. I read that and did not realize that’s what it means, if indeed, that is what it means.

    How do I turn off the display and merely get the variable.

    That was my source for the code int the first place, and I structured it as the example was shown for retrieving a variable, or, at least I thought I did.

    How do I turn off the display. Apparently, I don’t understand the terminology.

    get_bloginfo() => not echoed to browser
    bloginfo() => echoed to browser

    Your snippet above may do what you want with get_bloginfo instead of bloginfo is all.

    // *********** Begin
    $target_post_ID = url_to_postid(get_bloginfo('url') . '/category-slug/post-slug/');
    // *********** End

    Thanks David,

    That is the difference I was having trouble with … it works now using get_bloginfo()

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Why does bloginfo() echo to screen?’ is closed to new replies.