Last active
March 5, 2017 21:31
-
-
Save jhned/0a837cc69a08fbf9704155e522290733 to your computer and use it in GitHub Desktop.
Cross post-type check
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
<?php | |
/** | |
* is_news_or_post | |
* | |
* A custom boolean check for Hexadite so that we can test if we're on a news or post layout without repeating every single check every time we need to. | |
* | |
* @return bool | |
*/ | |
function is_news_or_post() { | |
$bool = false; | |
if ( is_singular( 'post' ) ) { | |
$bool = true; | |
} | |
if ( is_singular( 'news' ) ) { | |
$bool = true; | |
} | |
if ( is_post_type_archive( 'post' ) ) { | |
$bool = true; | |
} | |
if ( is_post_type_archive( 'news' ) ) { | |
$bool = true; | |
} | |
if ( is_tax( 'news-category' ) ) { | |
$bool = true; | |
} | |
if ( is_home() ) { | |
$bool = true; | |
} | |
if ( is_category() ) { | |
$bool = true; | |
} | |
if ( is_tag() ) { | |
$bool = true; | |
} | |
return $bool; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment