WordPress Code Snippets

A fresh mix of code snippets and tutorials

Static home page with separate posts page


In WordPress, static home page is possible via the General Settings. Or you can choose to display your blog posts. But how do have both?

Easy. Just add something like this to your functions.php file:

function get_posts_page_url() {
	if('page' == get_option('show_on_front')) {
		$posts_page_id = get_option('page_for_posts');
		$posts_page = get_page($posts_page_id);
		$posts_page_url = site_url(get_page_uri($posts_page_id));
	} else {
		$posts_page_url = site_url();
	return $posts_page_url;

Here is one way of using this function, using a link to display your blog posts:

<a href="<?php echo get_posts_page_url(); ?>">LINK</a>

More info

Learn more

WordPress Themes In Depth

Show Support

Like our new Facebook Page to show support!