Skip to content

Instantly share code, notes, and snippets.

@dannyconnolly
Created December 2, 2013 15:50
Show Gist options
  • Save dannyconnolly/7751533 to your computer and use it in GitHub Desktop.
Save dannyconnolly/7751533 to your computer and use it in GitHub Desktop.
Check if main blog page is used in wordpress
function is_blog() {
global $post;
//Post type must be 'post'.
$post_type = get_post_type($post);
//Check all blog-related conditional tags, as well as the current post type,
//to determine if we're viewing a blog page.
return (
( is_home() || is_archive() || is_single() )
&& ($post_type == 'post')
) ? true : false ;
}
// Usage: if (is_blog()) { echo 'Blog page!'; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment