• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress a2z

WordPress a2z

WordPress Dynamic API Reference

  • Home
  • Plugins
  • Themes
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / twentysixteen_categorized_blog() – Determines whether blog/site has more than one category.

You appear to be a bot. Output may be restricted

Description

Determines whether blog/site has more than one category.

Create your own twentysixteen_categorized_blog() function to override in a child theme.

Usage

$bool = twentysixteen_categorized_blog();

Parameters

Returns

bool True if there is more than one category, false otherwise.

Source

File name: twentysixteen/inc/template-tags.php
Lines:

1 to 26 of 26
  function twentysixteen_categorized_blog() {
    $all_the_cool_cats = get_transient( 'twentysixteen_categories' );
    if ( false === $all_the_cool_cats ) {
      // Create an array of all the categories that are attached to posts.
      $all_the_cool_cats = get_categories(
        array(
          'fields' => 'ids',
          // We only need to know if there is more than one category.
          'number' => 2,
        )
      );

      // Count the number of categories that are attached to the posts.
      $all_the_cool_cats = count( $all_the_cool_cats );

      set_transient( 'twentysixteen_categories', $all_the_cool_cats );
    }

    if ( $all_the_cool_cats > 1 || is_preview() ) {
      // This blog has more than 1 category so twentysixteen_categorized_blog() should return true.
      return true;
    } else {
      // This blog has only 1 category so twentysixteen_categorized_blog() should return false.
      return false;
    }
  }
 

 View on Trac

Published: 25th November 2019 | Last updated: 8th April 2020

Primary Sidebar

Information

Function name: twentysixteen_categorized_blog
Plugin ref: Twenty Sixteen
Version: 2.8
Sourcefile: inc/template-tags.php
File ref: inc/template-tags.php
Deprecated?: No
API Letters: B,C,T

Footer

WordPress a2z
WordPress a2z
WordPress Dynamic API Reference
WordPress 6.1.1. PHP: 8.0.28
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  wp-a2z.org
© Copyright WordPress a2z 2014-2023. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites