Skip to content

Instantly share code, notes, and snippets.

@mike-at-redspace
Forked from wesbos/is_blog.php
Created June 24, 2021 10:33
Show Gist options
  • Save mike-at-redspace/77010ae5633c22c203047f123a37153b to your computer and use it in GitHub Desktop.
Save mike-at-redspace/77010ae5633c22c203047f123a37153b to your computer and use it in GitHub Desktop.
WordPress is_blog()
function is_blog () {
global $post;
$posttype = get_post_type($post );
return ( ((is_archive()) || (is_author()) || (is_category()) || (is_home()) || (is_single()) || (is_tag())) && ( $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