How to Get URL for Blog Page When Using Static Homepage17th May 2011 | Posted by reza | 9 Comments
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.
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:
<?php $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