Forums

[resolved] Get Main Posts Page URL?? (5 posts)

  1. tjramage
    Member
    Posted 9 months ago #

    I am trying to get a "Back to Blog..." link at the bottom of the post when viewing single.php, but cannot figure out how to get the URL of the main posts page (where all the blog posts are). Using bloginfo('url') only provides the url to the front page...

    There's probably a really easy solution for this, but I just can't figure it out... :S

    Thanks,
    - Tim.

  2. tjramage
    Member
    Posted 9 months ago #

    At the minute I'm doing this:

    <?php echo bloginfo('url') . '/blog/'; ?>

    But that will only work when the blog posts page is on /blog... I'm hoping there is a better way of doing this which works 100% of the time.

  3. esmi
    Theme Diva & Forum Moderator
    Posted 9 months ago #

    Not tested but what about:

    <?php if( get_option( 'show_on_front' ) == 'page' ) echo get_permalink( get_option('page_for_posts' ) );
    else echo bloginfo('url');?>
  4. tjramage
    Member
    Posted 9 months ago #

    That works perfectly! Thank you :-)

  5. esmi
    Theme Diva & Forum Moderator
    Posted 9 months ago #

    Cool! :-)

Reply

You must log in to post.

About this Topic