What makes this annoying is that the count
is a wp_term_taxonomy
table.
So the way to do this is a custom query:
function wpse340250_term_count( WP_Term $term, $post_type) {
$q_args = [
'post_type' => $post_type,
'nopaging' => true, // no limit, pagination
'fields' => 'ids', // only return post id's instead of full WP_Post objects will speed up
'tax_query' => array(
array(
'taxonomy' => $term->taxonomy,
'field' => 'term_id',
'terms' => $term->term_id,
),
),
];
$term_count = get_posts($q_args);
return count($term_count);
}
So change the line to:
$va_category_HTML .='<span class="post-count">'.wpse340250_term_count($term, 'CUSTOM_POST_TYPE').'</span>';
Just set the correct posttype.
Related Posts:
- get_queried_object error How to show post count by month in the taxonomy page
- How to create A-Z index listing for custom post types?
- count_many_users_posts except current logged in user?
- custom post type category count shortcode
- WordPress Count posts within a custom post type
- Display custom post counts for author , not default posts
- How do I find the count of the current post?
- Get queried object for custom post type count
- How to make a list of posts displaying them 5 by 5 with a “next posts” link?
- Remove slug from custom post type post URLs
- How to get post content by calling ajax?
- How can I convert Posts into Custom type posts?
- Get category id from post id of a custom post type
- Limit widget to a specific registered sidebar
- WP_List_Table Inside Metabox Not Working on Submit
- Why get_next_post_link() or get_previous_post_link() doesn’t return the required links?
- Add metabox with media uploader in a custom post type [duplicate]
- Edit the “Post updated. View post” link
- How to hook get_terms() to only show count of posts that have custom meta
- Showing current taxonomy terms
- Newer/Older posts links display same posts on every page
- Nav menu of all posts in a custom post type
- Missing the first 6 Posts and displaying posts that are after the latest 6
- Add extra parameters after permalink?
- How do I check if a posts status is set to draft or pending?
- Adding Custom Taxonomy to WordPress default Post type
- wp_list_pages doesn’t work in hierarchical custom post type
- Post type hierarchy
- Show Two custom Post type and their posts on category page
- WP_Query is printing out only one post when posts_per_page is set to multiple
- How to get all posts except for one post from a certain custom post type?
- Exclude child pages from archive.php
- Using The REST API How To Pull All Custom Posts?
- How i can add ‘N’ page of ‘N’ pages under posts loop?
- How to convert custom post type based list to a dropdown list?
- List children on child post
- Restrict custom post type from appearing with ?post_types=
- How do I do this with WordPress? Taxonomies?
- Display Ad on Specific Categories
- Show titles, date of all posts on single category page
- Set up post page like JAMA articles
- Shortcode not working with post counter
- Changing default ‘posts’ parameters with register_post_type_args
- Allow users to create posts without logging in?
- Check post on publish for blank title
- Different Limit number of post on different archive page
- How to change “post_class()” for a custom post type?
- wordpress remove views from action links in a custom post
- Help With Warning on creating new Post types?
- Including link to custom post type in ‘wp_list_pages’ function
- Get an array wich contains the post_name of every post that has the custom post_type “pelicula”
- Custom post types and ‘new WP_Query’
- Showing custom post type categories in the menu
- I can no longer post or even save a draft, getting the error “A post type mismatch has been detected.”
- how to count the current posts terms
- Dynamic pages for linked categories and content
- Separate Content from gallery (custom post type)
- How to set the mainpage of a custom post type?
- displaying content of custom post type
- How to query Posts from a custom post type which contains a custom taxonomy?
- Send post changes to set email addresses (not users or subscribers)
- Does “Custom Post Type” can have page hierarhy option?
- How set template for “custom post type” individual post
- A sports wordpress website
- What is the best way to set the post category (Custom Post Type) automatically based on the one of the tags assigned to the post?
- Settings -> Reading -> Posts Page ->Blog — is not working in my website
- Is it possible to get the specific content on the search page?
- How to mass get post editor URLs
- How to create additional rendering for custom post types?
- open custom post type in popup window instead of page
- SELECT custom post type and its meta in SQL
- how to display posts content on the custom css popup by clicking on each title on the sidebar?
- How do I insert a custom post type query after a certain number of recent posts and then resume recent posts?
- How to show custom post count in archive page
- Adding specific custom fields (images) to post excerpt
- How to create editable sections in wordpress?
- Instructor can view, edit, delete only theirs courses
- How can I group by Taxonomy on Custom Post Type while filtering out based on custom Meta
- subtracting the current post form then whole loop, which is generating all CPT titles
- How to manage a dynamic multi-level page hierearchy system?
- Assign for all post of a post type a specific single-post template
- Widget area for individual posts (custom post type)?
- custum post inner page not taking single-gallery.php? it redirecting to archive page
- update a posts of other custom post type
- Show custom post type under last posts configuration
- Cannot use pages created on WP
- Custom Post Type used for FAQs Accordion
- How to Associate Posts with Pages
- delete custom post type using a submit form
- Why are my wp urls showing page not found?
- Post content stays the same but permalink changes ?
- Can I set a CPT title field to a dropdown with preset options if user is of a given type?
- Custom Post Type post not appearing
- Styling first post using Advanced Custom Fields
- How do I display the index position of a post from a custom post type?
- how to show Author post type count
- How to make a non-public post on wordpress approval?
- How Do I Add a Custom Post Type URL to Content?
- is therer any wordpress function to retrieve a specific html element from post content
- Post content in bootstrap modal