Created
March 21, 2012 12:08
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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