WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Why does bloginfo() echo to screen? (5 posts)

  1. kirkward
    Member
    Posted 1 year ago #

    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
  2. David Sader
    Member
    Posted 1 year ago #

  3. kirkward
    Member
    Posted 1 year ago #

    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.

  4. David Sader
    Member
    Posted 1 year ago #

    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
  5. kirkward
    Member
    Posted 1 year ago #

    Thanks David,

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

Topic Closed

This topic has been closed to new replies.

About this Topic