I figured out how to do it.
This code shows the number of posts on a page after clicking on a category in WordPress. Even if the post has lots of categories.
<?php $category = get_queried_object(); echo $category->count; ?>
I used this code as the code was in the category.php file and not part of the regular loop.
I hope this code helps anyone else if they are having the same type of problem.
Related Posts:
- Counting number of posts in multiple (sub)categories using shortcode
- selected option if current category is the value
- get_template_part based upon post’s category
- how to save selected option in variable for rest api category filter
- Setting default category base on theme activation
- Recent Posts Not Showing Only On A Specific Category Page [closed]
- Hide subcategories (widget)
- Alert Bar section within WP loop is displaying even though there are no posts
- Let Users Choose Post Categories
- Different post styles depending on category
- Display category name only once inside loop
- How to show only subcategories in parent category not parent category?
- how to show only specific category for a template
- Dilemma of Populating all the categories in a drop down list
- Display most popular posts of category
- Creating sub-categories via php
- Define specific category name in PHP
- Edit the_category (); for a hierarchical display
- JSON REST API WordPress only showing first 10 categories
- Category title output before opening title tag
- get taxonomy thumbnail and use it as a variable in code
- Include Parent Term in wp_list_categories
- How to array only one key from another array
- I’m trying to create an array with a foreach loop, but the array only stores the last item [closed]
- Get all categories post is not in
- Get latest post from all categories except one
- Displaying posts based on category
- How do I remove a category from a wordpress loop>
- How can i count the post added in relationship field, theme display
- Get categories names as an array to use it in theme settings
- Rewrite with pagination /foo/page/2/ to posts of a given category, page 2
- How to get the last category name of a child category?
- Use get() method to grab all categories and output inside another method
- Only show size attributes in product box woocommerce when available
- How to get category name or ID by post?
- Custom post type category not displaying category ID
- Argument for if term-> have child?
- How can I count ACF sub_field with a certain value
- How to get current post category details inside “loop”?
- How to separate categories with commas?
- How to hide posts of a specific custom category in WordPress?
- Show all tags within a category?
- Post not populating for custom post type based on category selection
- Add new post in existing categories using wp_insert_post
- How to change logo by category
- Problem with custom loop and wp_list_pluck [closed]
- Listing titles and custom fields of entries within subcategories
- random display categories – change url
- Displaying list of posts in category page
- Echoing a CSS class based on category of post in a list
- Alphabetically Ordered Category in WordPress
- Output category list inside array
- Do not duplicate posts with multiple categories in multiple loops
- Loading Posts & Category with Ajax
- Removing sidebar on category pages
- How to get current category
- WooCommerce: Display product categories to make IF statement
- Trying To Get Child Categories To Show, Issue With foreach Loop
- Define category ID using get_post_meta
- Taxonomy term count
- Show parent categories of the current category
- is user member of a group, show them categories [closed]
- Showing Subcategory Name/Link Instead of Parent Category
- How to check if a category has a parent and child categories?
- WordPress custom taxonomy
- How To Pass Array To get_the_category_by_ID() and Get An Array Back?
- go to home page when i select default in select-box
- Finding and removing duplicates within WP Arrays
- Adding wp_list_categories to a specific div that was appended using jQuery
- Using multiple variables to assign categories to an array
- Compare current post Category in select menu
- Get category id when SEO URL is turned on
- Display latest post from WordPress Featured Category that is also in X,Y,or Z categories
- Get the list of post categories
- Remove Custom Post Category In WordPress Slug Using .Htaccess
- Display Sibling WooCommerce Product Categories on Archive Page
- Pagination at category doesnt work with same name of page
- Woocommerce. Get a list of products in the current category on the archive page and product page
- Wrong Number of Products When Hiding Subcategory Products From Showing In Parent Category
- How to show categories and date on posts
- display the months of a specific category
- I need to display posts in subcategory beside posts in main category
- Add Custom Category Description When Empty
- Order category posts by last word of custom field
- How do I edit the terms output args or array data?
- Add a product category to a specific product via a button
- List sub categories and corresponding posts of a parent category
- Add a “custom field” to a category that can be retrieved when viewing the category page with get_post_meta
- Change category thumbnail size
- Allow two posts (from different categories) to have the same slug
- Get main parent category for post (WordPress/Advanced Custom Fields)
- Dropdown category field inside repeatable metabox
- Get nice name of category from slug (remove dashes of category)
- Display Visual Composer shortcode if a post belongs in specific categories
- Child-Theme Category View with modified permalinks (%category% removed)
- admin panel – How to remove “delete” button from category editing page
- Like and Dislike Buttons on Post with Counter – Only allow one click per post per user session
- Display featured posts first, then display all others within a specific category in WordPress
- Help with get_categories code
- Is it possible to go to the next post in the same category?