public_html/wp-content/themes/LocalTwo/inc/template-tags.php
/**
 * Returns true if a blog has more than 1 category.
 *
 * @return bool
 */
Returns true if a blog has more than 1 category.
@return bool
Returns true if a blog has more than 1 category . @return bool
function divertheme_categorized_blog() {
	if ( false === ( $all_the_cool_cats = get_transient( 'divertheme_categories' ) ) ) {
		$all_the_cool_cats = get_categories( array(
			'fields'     => 'ids',
			'hide_empty' => 1,
			'number'     => 2,
		) );
		$all_the_cool_cats = count( $all_the_cool_cats );
		set_transient( 'divertheme_categories', $all_the_cool_cats );
	}
	if ( $all_the_cool_cats > 1 ) {
		return true;
	} else {
		return false;
	}
}
function divertheme_categorized_blog ( ) { if ( false === ( $ all_the_cool_cats = get_transient ( 'divertheme_categories' ) ) ) { $ all_the_cool_cats = get_categories ( array ( 'fields' => 'ids' , 'hide_empty' => 1 , 'number' => 2 , ) ) ; $ all_the_cool_cats = count ( $ all_the_cool_cats ) ; set_transient ( 'divertheme_categories' , $ all_the_cool_cats ) ; } if ( $ all_the_cool_cats > 1 ) { return true ; } else { return false ; } }
Returns true if a blog has more than 1 category.
Returns true if a blog has more than 1 category .
// Create an array of all the categories that are attached to posts. // We only need to know if there is more than one category. // Count the number of categories that are attached to the posts. // This blog has more than 1 category so divertheme_categorized_blog should return true. // This blog has only 1 category so divertheme_categorized_blog should return false.