How to Get URL for Blog Page When Using Static Homepage

By default, a WordPress website displays the blog page, which is your most recent posts, on the front page. But many WordPress users want to have a static front page or splash page as the front page instead. Fortunately, WordPress allows you to select a different page for your home page. You can also create another page that you use as blog page. You can read how to create static homepage: link.

Get URL for Blog Page

Once your WP site has been set up to use a static front page, You maybe need the URL of the page that has been designated as the blog page.

Here’s the code to get the link:

$posts_page_id = get_option( 'page_for_posts');
$posts_page = get_page( $posts_page_id);
$posts_page_title = $posts_page->post_title;
$posts_page_url = get_page_uri($posts_page_id  );

$posts_page_url is the url to blog page and $posts_page_title is the page title

Now You can use it in HTML a tag to link to your blog page, for example:

<a href="<?php echo $posts_page_url; ?>" title="<?php echo $posts_page_title; ?>">blog</a>

Hope this post helps

Esmi and Tirussell from

9 Comments to “How to Get URL for Blog Page When Using Static Homepage”

Add Comments (+)

  1. Kevin says:

    Good article. But we are able to configure a static page as homepage and another static page as the blog page via wp-admin->settings->reading settings. Not sure why we should add the code manually. :-)

  2. kevin says:

    I’d recommend get_page_link() which will return the complete link of the blog page rather than get_page_uri() that will just return the page’s uri and which can lead to some 404 in some cases.

  3. nice stuff, i enjoyed reading this. thanks for sharing with us.

  4. Evergreen says:


    But i have bug:
    In me blog page for post is not front page and when i echo $posts_page_url = get_page_uri($posts_page_id ); result is “sample-page” – I don’t know why?

    I fix it – just changed get_page_uri() to get_permalink.

    thanks for sharing!

  5. Beat says:

    Thanks a lot for this information how to get the URL of the blog page. This is really not very well documented elsewhere.

  6. Jeffrey says:

    Howdy! Do you know if they make any plugins to assist with Search Engine Optimization?
    I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good results.
    If you know of any please share. Thank you!

Leave a Reply


Amazingly Beautiful WordPress Themes