Back WordPress

How to Get URL for Blog Page When Using Static Homepage

WRITTEN BY ON 17 May 2011
10,361 VIEWS • SHARES
0 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

PHP

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

<?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  );
?>

Join the discussion

Comments will be moderated and rel="nofollow" will be added to all links. You can wrap your coding with [code][/code] to make use of built-in syntax highlighter.