As the Codex says, this is the code block to query for only the Top Label categories — the parents. With this, I used the PHP function count()
.
<?php
$args = array(
'parent' => 0,
'hide_empty' => 0
);
$categories = get_categories( $args );
echo count( $categories );
?>
Related Posts:
- How to get the number of child categories a specific parent category has?
- Warning: sizeof (): Parameter must be an array or an object that implements Countable, On products pages
- Pagination is not working properly in Product Category/Tag pages
- There any way to get de percentage of number of post by user and category?
- Get Number of total Parent Categories for Custom Taxonomy
- Single.php Category Post Count
- If x comments in a post move post to category y
- Count tags for a specific category
- Show the amount of posts in a tag in a specific category has
- Change categories count to include media attachments
- How to exclude posts from category posts count
- Show the number of the post
- List all categories and count number of posts within based on custom date
- Count how many posts have a specified tag AND category
- Add subcategories posts to the counts column at the admin’s categories list
- Category count but only if category has at least one post
- Create a category list page
- How do I use the same post slug for different Categories?
- How to display only 3 main categories, separated by commas, since they are marked in the post?
- Woocommerce product categories order [closed]
- How do I create a way for users to assign categories to a post from the frontend?
- How to hide a specific category posts in my monthly archive?
- Give specific category its own permalink structure
- Create terms when registering taxonomy?
- How to set up sub-categories for author pages?
- Add category to custom post type automatically, using category slug
- How do I edit pre_get_post for the category the user is currently in?
- Assign different category colours to different categories in the main menu
- wp_list_categories, Add class to all list items with children
- Display Only One Category
- Display only one result from “get_the_category_list”
- Get term by slug in Gutenberg
- How to get post category title within the loop?
- If category is in parent category?
- Hide posts of a certain category unless logged in
- Show only first children level of current category?
- Problem displaying one post from each category
- How do I automatically put categories and their descriptions on a WP Page?
- Taxonomy filter all children
- RSS/XML of all Categories and/or Tags
- URL path for wordpress categories
- get_posts and multiple categories
- How do I get rid of “category” from my URL structure?
- Only one post is showing on category page, why?
- Have different permalinks based on category
- How do I output all category with custom field?
- Add /category/ to an author archive page
- Remove subcategory and category with some rules from permalink
- How can I edit the ‘Most Used’ tab in the categories meta-box to show another custom taxonomy?
- category pagination got broken suddenly
- How to remove specific categories from posts?
- how to get full category path including parent and subcategories
- WordPress get from single.php back to the right category page
- Categories are not listing their respective products
- Include WooCommerce product to all child categories
- Two columns in homepage each with one category
- Pagination on category.php and tag.php not working
- WordPress link to post links to category (loop)
- How do I attach a page to a category similar to how we attach media to a post?
- Display all product tags associated with a specific product category
- How replace individual elements in the RSS feed with a single string
- Category url generate 404 error
- Adding a page summary to a specific page
- Adding a block with query in homepage
- Add a category on all archive category pages
- what file I need to create to work date archive links?
- multiple values in an array for category__and does not work with WP_Query
- Assigning certain pages or posts to use the template of the parent page or category
- I need advice on how to structure the categories according to the layout i have
- How to get posts using category slug in ClassiPress?
- Assign author to category and not only posts
- Add properties to term object
- How to fetch common posts from two feeds?
- Display all Categories
- How to set acf color field as background color to product category
- How to target all woocommerce categories that don’t have any subcategories in them?
- How to add all subcategories as submenu in WordPress menu
- echo $category[0]-> cat_name; shows only one category name
- Category pages resolving with and without category prefix
- Is there a way to allow users to customize their feed view?
- Number of categories slowing down the site
- Change post category within pre_get_posts
- Subcategory Page 404ing
- displaying one category on one page
- Ajax Category add doesn’t update the list table custom column
- Question About Messing With Category Pages and Descriptions
- how to get postmeta info based on multiple categories?
- create post with main category and other categories from admin panel
- get_posts – require all categories
- List Terms by category
- Add advertising box to a specific category page
- How do you add Author and date Published on Category Pages?
- Twenty Eleven Theme [duplicate]
- display certain category on custom template page
- List products from current category
- comments_number fails to print
- How to show posts of a specific category
- How to show child category name & post from it’s parent [closed]
- Function to reference post meta in place of category Woocommerce
- Category Redirection Problem