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
- Display current category title on category page
- Inject post (from specific category) between posts in Loop
- Display user’s total comment count outside The Loop
- Allow authors to post only in categories they create in WordPress
- List all categories but exclude current post category on single post page
- Specific Loop For 2 Within Each
- Categories Template Assistance
- Edit category output
- Error: array_map(): Argument #2
- Problems with function on function.php
- Use template for posts with a particular category grandparent
- Count number of published posts by type
- Custom Loop through category menu to include sub categories
- Different background-image by category
- Get posts with at least one category in common with current post?
- Woocommerce – remove product from category
- Get category name from custom loop and echo it once
- Custom category code not showing all posts
- Adding country tags automatically
- hover image appears below placeholder instead of overlayed
- get current product name in functions.php
- Filter Select results based on selection
- How to exclude category ID from Looper in WordPress
- Add a specific part of current category page url to shortcode
- how do I get a specific post from a post with a subcategory in WP
- WP grandchild categories in nested ul li
- Pass Category Name, Description and Photo into variables to pass to jQuery
- How to show single category archive
- How to pick the default selected value in wordpress dropdown?
- Applying A Category to Existing Posts Where Page Title Matches Regex
- Get page that displays all children of taxonomy parent
- Hide subcategories (widget)
- Let Users Choose Post Categories
- How to show only subcategories in parent category not parent category?
- Dilemma of Populating all the categories in a drop down list
- Display most popular posts of category
- JSON REST API WordPress only showing first 10 categories
- get taxonomy thumbnail and use it as a variable in code
- Get all categories post is not in
- Get latest post from all categories except one
- Rewrite with pagination /foo/page/2/ to posts of a given category, page 2
- Use get() method to grab all categories and output inside another method
- Only show size attributes in product box woocommerce when available
- 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”?
- Displaying list of posts in category page
- Echoing a CSS class based on category of post in a list
- is user member of a group, show them categories [closed]
- Showing Subcategory Name/Link Instead of Parent Category
- WordPress custom taxonomy
- Finding and removing duplicates within WP Arrays
- Using multiple variables to assign categories to an array
- Compare current post Category in select menu
- Get the list of post categories
- Remove Custom Post Category In WordPress Slug Using .Htaccess
- 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
- How to show categories and date on posts
- Add a “custom field” to a category that can be retrieved when viewing the category page with get_post_meta
- Allow two posts (from different categories) to have the same slug
- Get main parent category for post (WordPress/Advanced Custom Fields)
- Child-Theme Category View with modified permalinks (%category% removed)
- Category Page Displaying all Pages
- How to move a post from one category to another
- How to enable HTML tags in category description without breaking the category page
- Trying to show the category of a post in the post display
- Create category after theme setup and modify the default one
- Link to index.php from home.php?
- Hide a specific category title from displaying on site
- Warning: count(): syntax problem of the count () function
- Return to the beginning of the results of a for loop
- Populate Posts based on category selected using AJAX that means without page refresh
- random woocommerce categories are not showing when count enabled?
- Customizing the output of the archive and category widget without altering the original behavior of the widget
- How to Retrieve All Category Images on Front-End
- Displaying 3 Category Posts differently
- Code works on page-example.php by not category-example.php
- get_category display only 1
- How to list categories by page id in wordpress
- WordPress using get_term to retreive slug not working as expected
- Showing the project type in HREF
- Front end post submissions do not get submitted in the category
- divide custom field values in div every two values
- Make an array listing custom taxonomy
- Get category id for a custom category and display it in a class
- Trying to exclude posts from a category on the home page
- Is there a way to randomize and connect a background and header image?
- wp_get_archive for category returning different URLs on different but similar sites
- Showing Subcategory’s Name and Link Instead of Parent Category’s
- How to get the count for each taxonomy term
- dynamically filter by category via sub-menu
- Get unique post in parent category
- Incomplete term slugs output from a foreach loop with get_the_terms
- How to add together (get the sum) a field from all author’s posts
- Remove /category/ from category (archive) page URLs (without using a plugin)
- How to insert the first letter in uppercase [closed]
- How to limit number of posts in the certain category and exclude the oldest post automatically