Skip to content

Instantly share code, notes, and snippets.

@jhned
Last active March 5, 2017 21:31
Show Gist options
  • Save jhned/0a837cc69a08fbf9704155e522290733 to your computer and use it in GitHub Desktop.
Save jhned/0a837cc69a08fbf9704155e522290733 to your computer and use it in GitHub Desktop.
Cross post-type check
<?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