Skip to content

Instantly share code, notes, and snippets.

@kellenmace
Created June 16, 2016 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kellenmace/9ef19dd86580cb7e63720b396c8c2721 to your computer and use it in GitHub Desktop.
Save kellenmace/9ef19dd86580cb7e63720b396c8c2721 to your computer and use it in GitHub Desktop.
Get Blog Posts Page URL in WordPress
<?php
/**
* Get blog posts page URL.
*
* @return string The blog posts page URL.
*/
function km_get_blog_posts_page_url() {
// If front page is set to display a static page, get the URL of the posts page.
if ( 'page' === get_option( 'show_on_front' ) ) {
return get_permalink( get_option( 'page_for_posts' ) );
}
// The front page IS the posts page. Get its URL.
return get_home_url();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment