get_option( 'page_for_posts')
will give you the id of the designated posts page if get_option( 'show_on_front' )
is set to page
. so something like:
if( get_option('show_on_front') == 'page') {
$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 );
}
else $posts_page_title = $posts_page_url = '';
should work.
http://codex.wordpress.org/Option_Reference
http://codex.wordpress.org/Function_Reference/get_page
http://codex.wordpress.org/Function_Reference/get_page_uri
Thanks for cluing me into ‘page_for_posts’ – your solution works like a charm. I added the following to my functions.php:
if ( ! function_exists( 'mytheme_get_posts_page' ) ) :
function mytheme_get_posts_page($info) {
if( get_option('show_on_front') == 'page') {
$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 );
}
else $posts_page_title = $posts_page_url = '';
if ($info == 'url') {
return $posts_page_url;
} elseif ($info == 'title') {
return $posts_page_title;
} else {
return false;
}
}
endif;
seems like this is something that people who are using a static homepage/wordpress as a cms would like access to. What’s the best way to suggest something similar to this for consideration as an out-of-the-box function in future releases?
You could try posting something in the Requests & Feedback forum.