Skip to content

Instantly share code, notes, and snippets.

@jhebb
Forked from wesbos/is_blog.php
Last active December 16, 2015 02:59
Show Gist options
  • Save jhebb/5366264 to your computer and use it in GitHub Desktop.
Save jhebb/5366264 to your computer and use it in GitHub Desktop.
Add is_blog() function to WordPress
function is_blog () {
global $post;
$posttype = get_post_type($post );
return ( ( is_archive() || is_home() || is_single() ) && ( $posttype == 'post') ) ? true : false ;
}
Usage:
<?php if (is_blog()) { echo 'You are on a blog page'; } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment