Support » Fixing WordPress » How to get the posts home URL?

  • Resolved frntk

    (@frntk)


    Hello all!

    How can I get a URL to the “posts home” (i.e., the page that shows my posts when my “front page” is a static page)?

    I think get_option(‘home’) might have done it but it’s deprecated now. I looked aroundd docs but could not find anything. Thanks for your help!

Viewing 6 replies - 1 through 6 (of 6 total)
  • I think you want bloginfo(‘url’). See the Codex here.

    Thread Starter frntk

    (@frntk)

    Hi vtxyzzy! Thanks for your reply.

    That’s what I’m currently using but it’s not what I’m looking for. Let me elaborate.

    – My blog is set up at http://domain.com/ (this is what bloginfo(‘url’) returns)
    – My front page is set to display a “static page” (I called this page “home”)
    – My posts page is set to display another page I created called “news”.

    What I want is a link back to “http://example.com/news/” when I’m in single.php displaying posts, but bloginfo(‘url’) gives me the front page URL.

    (sidenote: oddly, when I use get_bloginfo(‘url’) it gives me the current post URL! I’ll research more into this).

    Thanks!

    I think this is what you want:

    <?php $permalink = get_permalink( $id ); ?>

    Where $id is the ID of your news page.

    You can use the following, which doesn’t require you to find the ID of the page (and will also update if you change pages)

    <a href="<?php echo get_permalink( get_option( 'page_for_posts' ) ); ?>">View News</a>

    It’s the same as vtxyzzy’s, but it just gets the option you selected as the posts page, as opposed to a static ID.

    Thanks for the tip!

    Thread Starter frntk

    (@frntk)

    That’s wat I needed. Thanks a lot, to both of you, for your help!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to get the posts home URL?’ is closed to new replies.