Questions tagged [count]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
17
votes
5answers
3k views

How to mark every 3rd post

I'm working on a WordPress site for my band and I'd like to mark every 3rd post on our blog page to have a special class applied to it, anybody have any pointers on how to achieve this? Any help is ...
10
votes
2answers
33k views

Counting the posts of a loop (WP_Query)?

I tried this way to display NO of post: <?php $news_2 = new WP_Query( array ('post_type'=> 'jobs','posts_per_page'=> '10' , 'meta_key' => 'status_for_jobs','meta_value' => '1') ); ...
8
votes
2answers
5k views

Count & Display Database Queries

I'm looking for an solution how I can count and display all queries in a WordPress site. Does anybody know, if there is an good plugin? Otherwise it would be an solution to check the queries on the ...
8
votes
3answers
5k views

How to Display a List of Users Who Have Made at Least 1 Post?

What I would like to do is have a list of users who have contributed at least one post. I need to show the following: [User photo] | [User Name] | [User post count] e.g. [photo] Joe Bloggs(8) I ...
7
votes
6answers
47k views

Count posts within a custom post type and specific category

I'm looking to count how many post live within the custom post type called "videos", but only the ones from the category called "work". <?php $count_posts = wp_count_posts('videos'); echo $...
7
votes
2answers
5k views

Return only Count from a wp_query request?

Is it possible with the standard build-in tools in Wordpress to get wp_query to only return the count of an query? Right now, I’ve a query which has several meta_queries but what the only thing I’m ...
6
votes
2answers
1k views

How to Display Network Post Count?

Is it possible to display the total post count for all blogs in a Network? get_blog_count and get_user_count do so for blogs and users, but I can't find any methods to do so for post count.
5
votes
7answers
9k views

Category and children post count

I've a situation where I cannot get correct post count from category... and I've tried everything but customizing wp_list_categories with walker. So I've category hierarchy: cat1 cat2 (total 8) ...
5
votes
3answers
8k views

Hide the post count behind Post Views (Remove All, Published and Trashed) in Custom Post Type

I need to hide/remove the numbers behind the Edit screen in the backend. All (30) | Published (22) | Draft (5) | Pending (2) | Trash (1) As I am running a multi author blog and each author has just ...
5
votes
4answers
3k views

WP 3.5 and Galleries - how to count images?

I'm trying to figure out how to count and display the number of images in a gallery with WP 3.5. I was following an old post on Ottopress, querying the DB for attachments but it seems the galleries ...
4
votes
1answer
8k views

How to display 2 equal columns of li based on the count of items in wp_nav_menu divided by 2?

I would like to display a custom 3.0 menu in my sidebar. I want the list to be in order of name, and the list to be sequential down the list of the left column and flow down, then into the right ...
4
votes
2answers
2k views

Total word count for posts by one author

How can I get a total word count of one author's posts? I would like to be able to see what the total word count of their output is, summed across all of their posts (ideally with a breakdown by ...
4
votes
2answers
1k views

Count the number of images uploded on the website

I mention "full website" because I don't need the number of attachments on one post (as answered in many questions). I basically need a function that returns the number of uploaded images (attached ...
4
votes
1answer
553 views

show number of open comments on custom dashboard

On my custom dashboard, I want to show the number of total new comments (somehow like "right now"). Just like "You have ... open comments to take care of". So all I want is the total number not a list ...
4
votes
3answers
5k views

Taxonomy count per Post type

Below is the code i use to output the post tag (taxonomy) count/number. I want to be able to split the count based on post type that the taxonomy features in (rather than the total number). So i ...
4
votes
3answers
3k views

count posts from custom taxonomy terms by year

I want to build statistics-like tables with the count of posts in given custom taxonomy terms and display them by year along with the total post count from that year. For example: 2014 |...
4
votes
1answer
3k views

Count posts or custom post types from last 24 hours (or from today)

I would like to display count for custom post types (or posts) which was published that day (last 24 hours or TODAY). I use this snippet to get count of all posts from "posts" or from "custom post ...
4
votes
2answers
2k views

Comment Count for each Comment Author

In WordPress 3.4.1: I am trying to add the Comment Author's total number of comments beside their info. (name + date/time) in the comment's list. Here is the SQL that I am using: $count = $wpdb->...
4
votes
1answer
2k views

Display user's total comment count outside The Loop

How do I display a user's total comment count outside The Loop? I use this code to display comment count inside the loop: <?php global $wpdb; $user_id = $post->post_author; $...
3
votes
4answers
7k views

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 ...
3
votes
2answers
9k views

Count post that have specific meta value

How do I count only the post that have a specific custom meta field value? $productCount = wp_count_posts('product'); echo $productCount->publish; That gives me all the total of all the post. ...
3
votes
1answer
1k views

How to cache a shortcode functions output?

I would like to show on my startpage the total count of posts in a WordPress Multisite. Those are nearly 7000 in 500 Blogs. So I made a function which has to go through every blog to count the posts. ...
3
votes
2answers
53 views

Show weekly posts statistic in WordPress

I create a table in the footer. I would like to show some statistics, like total posts, weekly posts, total posts of the specific category. I just echo total posts with wp_count_posts()->publish; ...
3
votes
1answer
710 views

How to count current user's pages?

There are a lot of answers on how to count users posts by using: <?php if ( is_user_logged_in() ) { global $wpdb; $user = wp_get_current_user(); $where = ...
3
votes
2answers
456 views

Audio or playlist shortcode condition according to the amount of files on attachment page

My reason for doing this is for a music & entertainment site where users will have the ability to share music and videos on other websites via embed code. I'm using the audio.php and video.php ...
3
votes
1answer
1k views

Count user posts by type and date

I use the following code to count user posts by specific post type: function count_user_posts_by_type( $userid, $post_type ) { global $wpdb; $where = get_posts_by_author_sql( $post_type, TRUE,...
3
votes
1answer
152 views

WordPress comment count to include attachment comments

How can I make the comment count on a post on my index page include comments that have been made on, in my case, individual gallery pictures that are included in the post? It seems that comments made ...
2
votes
6answers
8k views

Get count of custom post type created by current user

I'm trying to get the count of published posts in a custom post type for the current user (to display on a profile page). I found this here on the forums: <?php global $wp_query; $curauth = $...
2
votes
2answers
1k views

Number of items in a menu

I can't find if WordPress stores the number of items in a menu. Basically I need to find out how many items are in a menu to work out the percentage each item should take up in the header bar. Is ...
2
votes
1answer
16k views

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 ...
2
votes
3answers
3k views

Post count per (day/month/year) since blog began

I'm looking to echo the number of posts per month since the blog began, and for months where there was no posts echo '0'. This is the output I want: January 1, February 3, March 8, April 3, ... ...
2
votes
2answers
2k views

How do I count how many top level categories there are?

I need to calculate some dynamic CSS based on how many top level categories exist. (NOT how many posts are in a category, or how many categories a post belongs to... Nothing about posts at all, just ...
2
votes
1answer
112 views

Show that current post is number X out of X

Is it possible to echo at the end of a post which number the current post is? For example; Say you're viewing the 4th most recent post out of a total of 10, somewhere at the foot of the post I need ...
2
votes
4answers
6k views

How to count get_users query?

I have been searching high and low for a way to count the amount of results from a get_users query. Most of what I found is to count the total number of posts in a post query, but nothing for ...
2
votes
1answer
2k views

How to get the number of child categories a specific parent category has?

How do we count the number of child categories of a parent category? I am using a custom taxonomy, called: "authors". I found this code, which does count the number of child categories, but only ...
2
votes
2answers
318 views

Check if an array of posts has posts from a specific category

I have an $array that prints out to be as follows. Array ( [post-12] => 12 [post-160] => 160 ) What WordPress function could I use to check how many of the post ID's in the array belong to a ...
2
votes
2answers
3k views

Count total number of post in foreach loop

I used the the following script (only with get_permalink....) to display posts from a post type where the post author has an extra meta field on his user page: <?php // get users from user page ...
2
votes
1answer
102 views

taxonomy list display custom post count

I use $term->count to display post count but it displays the total count of all type of custom posts attached to taxonomy... I just want to display the count of only a specific custom post type ...
2
votes
2answers
827 views

Count number of published posts by type

I have this code, but it shows the total number of posts published by post type 'code'. <?php $count_posts = wp_count_posts('code')->publish; echo $count_posts; ?> I have 2 post types: '...
2
votes
1answer
289 views

Show the author's count of total amount of posts assign to a custom taxonomy term

I have assigned a custom taxonomy named Highlight to posts and I have added a term to it named Featured.  Whenever I want to feature a post, I simply assign it to featured.  To each author, I want ...
2
votes
1answer
255 views

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 ?
2
votes
0answers
41 views

How to trace/fix false $term->count, rogue term relationships?

On a page listing terms from my 'source' taxonomy, I loop through foreach term... foreach ($all_source_terms as $source_term) { // some stuff echo $source_term->count; } When I echo $...
2
votes
0answers
41 views

get_queried_object error How to show post count by month in the taxonomy page

Can anyone help me please. i want to show custom post type count by month of taxonomy in archive page for current year. Example: January 24 February 43 March 5 April 6 and etc. This code is help ful ...
2
votes
1answer
480 views

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';...
2
votes
1answer
1k views

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" ...
1
vote
2answers
1k views

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'...
1
vote
1answer
3k views

Count posts in category including child categories

I have found this code somewhere, it counts posts but only which are under specific category. I would appreciate if someone could expand this so it would count all posts which also belong to its child ...
1
vote
1answer
113 views

Count to how many categories a post belongs to

Is there a possibility to count to how many categories a post belongs to?
1
vote
2answers
139 views

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 ...
1
vote
4answers
150 views

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 ...

1
2 3 4 5 6