Skip to content

Instantly share code, notes, and snippets.

@dnaber-de
Created March 21, 2012 12:08
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 dnaber-de/2146513 to your computer and use it in GitHub Desktop.
Save dnaber-de/2146513 to your computer and use it in GitHub Desktop.
Wordpress function to get the URL of the posts index page if this is not the home URL.
/**
* gets the link to the article index
*
* @global $blog_id
* @return string
*/
function get_page_for_posts_url() {
global $blog_id;
$index_id = 0;
if ( is_multisite() )
$index_id = ( int ) get_blog_option( $blog_id, 'page_for_posts', 0 );
else
$index_id = ( int ) get_option( 'page_for_posts', 0 );
if ( 0 === $index_id )
return get_home_url( $blog_id );
return get_permalink( $index_id );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment