Articles of count

What is the best way to count and display the number of posts?

I have a section in my site where I display the 10 most popular posts. Now, I want to display a number, from 1 to 10, besides each post. Like this: Top 10 posts post a post b post c and so on… I implemented a counter inside the while loop. I initialized the counter […]

count_many_users_posts except current logged in user?

Is there a way to count and show the count of all author posts in a custom post type except the current logged in user? I was hoping there’s a way to do it with count_many_users_posts but it doesn’t appear there is a way to exclude authors, only include them. I’ve done multiple searches but […]

Count posts with specific term_meta

I have a custom post type that have many taxonomies. In the front end, a user can assign a ‘category’ (term_meta) value to the taxonomy – hardware or software. I wanted to be able to count how many term_meta posts there were. $base_array = array( ‘posts_per_page’ => -1, ‘fields’ => ‘ids’, ‘post_type’ => ‘cpt’, ‘post_status’ […]

Count number of post in Taxonomy?

wp_count_terms() counts the number of terms in a taxonomy but not the number of post that have those terms and I’ve found that wp_count_post() does not accept a taxonomy. So whats a guy gotta do to count the number of post in a taxonomy term? Example: Term: Apples Post: 89 (this is what I want […]

How to count custom post types with conditional operators

I have a custom post type that I want to use an if/elseif/else statement with. If post count of post type is equal to 1 do X, elseif post count is greater than 1 do Y, else do Z. This is the code I’ve come up with so far, but when I add in the […]

Count to how many categories a post belongs to

Is there a possibility to count to how many categories a post belongs to?

Count posts that have specific taxonomy term attached

When upgrading our portfolio I’m looking for something that shows the number of posts in a (current) category of a post type. Example: I have a category with ‘features’. Each feature has it’s own description, apps related and blog related posts page I’m fetching the current category with: <?php $cat_id = get_query_var(‘cat’); ?> and get […]

wp_count_posts, wp_count_terms and wp_count_comments for specific user?

Is there a way for the functions wp_count_posts, wp_count_terms and wp_count_comments to return their results only for a specific user, possibly by using a user’s ID? I’m making a custom “Right Now” dashboard widget for a custom post type and I need it to show data for the current user only, not for the whole […]

Double count view in archive.php

I’m having a hard time using this snippet I’m getting double views each time the post is queried. This is in my functions.php file: function getPostViews($postID){ $count_key = ‘post_views_count’; $count = get_post_meta($postID, $count_key, true); if($count==”){ delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, ‘0’); return “0”; } return $count; } function setPostViews($postID) { $count_key = ‘post_views_count’; $count = get_post_meta($postID, […]

Total Word Count For Posts And Comments By One Author

How can I count words in posts + tags + comments and display the number of total words used by each author ?