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 ...
5
votes
3answers
9k 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 ...
4
votes
3answers
6k 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
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 ...
10
votes
2answers
37k 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') ); ...
2
votes
1answer
108 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 ...
1
vote
1answer
570 views

Count singular post views automatically

I'm trying to add some function to each loop called in the themes. What I'm doing is I add a function to count post view from here post views without plugin, to use the function I need to add this ...
-1
votes
1answer
3k views

Increasing post view count automatically [duplicate]

I am testing a ranking system for posts, and I'd like help with the below: Upon publishing a new post, I'd like the post view count to immediately have a random number between 829 and 1013 added to ...
1
vote
3answers
18k views

Display the number of published posts for each custom taxonomy term?

I do have a custom taxonomy called "countries". How do I get each term (country) with the number of its published posts in brackets, like the following: Uruguay (3) Chile (5) Thailand (2) etc. With ...
6
votes
2answers
2k 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.
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 ...
9
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 ...
3
votes
1answer
4k 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 ...
3
votes
2answers
11k 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. ...
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->...
1
vote
2answers
5k views

Specific Loop For 2 <div> Within Each <li>

I need to create a loop that can logically be described as the following for a carousel: Requirements: 3 Loops 2 Posts Per Loop No Duplicates Order by Post Date Visual: < Start Loop #1 > <...
0
votes
2answers
872 views

Set font size automatically according to number of words in post

By submitting a post for publication will be made a count of the number of words in the post and will add a div with font-size pre-set according to the number of words. If the post contains up to 50 ...
0
votes
1answer
538 views

User Published Post Count

I am need to get this function to get user post count where we get published posts within 24 hours, if none in 24 hours then within the week. Ex. David Green - 10 Posts within 24 hours Vivian ...
0
votes
1answer
229 views

Count custom post types with a specific meta value

We have a custom type called books. In a template, we need to show the counts of books that have the book_type as Fiction Non Fiction Novel Short Stories We use ACF Pro, and the above field is set ...
3
votes
1answer
745 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 = ...
2
votes
1answer
17k 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 ...
1
vote
1answer
2k views

Problem with get_posts, tax_query and counting the number of posts

I want to count the number of posts that has simoultaneously 3 different taxonomies. THe code i'm using is this: $products = get_posts(array( 'post_type' => 'products', 'posts_per_page' =&...
1
vote
1answer
193 views

Limit tag word count

I want to limit user to enter post_tag only words of two not more that. If any of the tag is more than two words the user caanot publish the post. I need to use this function to count word. function ...
1
vote
2answers
80 views

Redirect based on user post count

I'm at a loss.. I wanna check the current users post count. If the post count is 1, the user should be redirected. I have tested the following code: add_action( 'template_redirect', '...
1
vote
2answers
3k views

Custom Post Type Category List & Post Count

I'm looking for Cutom Post Type Category List & Post Count. Here is my code.. <?php $taxonomy = 'project-tags'; $tax_terms = get_terms($taxonomy); ...
0
votes
2answers
3k views

Count posts for each year

I'm using the following code to list all years from my blog, I guess we can call it an archive. <?php $years = $wpdb->get_col("SELECT DISTINCT YEAR(post_date) FROM $wpdb->posts ORDER BY ...
0
votes
1answer
621 views

Alternate custom content in the loop

I have a slick slider scrolling through some posts. I also have a couple of divs displaying between every third slide some some different content like so: <div class="slick-slider pin-news-...
0
votes
1answer
420 views

Taxonomy list. Order by a specific custom post type count

I have a custom taxonomy and two custom post types (A and B post types). I created a taxonomy list and this list also display B posts type count of taxonomy. Taxonomy list is ordered by post count. ...
0
votes
1answer
664 views

Add character count to custom metabox

I know of a way to add a character counter to the excerpt metabox in WP, but I would like to add a character counter to a custom metabox. The following script is getting the counter in the metabox, ...
0
votes
1answer
944 views

How to use global post counter in the loop?

In the Loop use this code <?php $count = $wp_query->current_post; echo $count; ?> On first page post counts from 0 to 14, but from second page post counts from 0 to 14 to. How use global ...
0
votes
1answer
3k views

How to change post count in wordpress loop?

Hey I am attempting to customize my WordPress post loop to create different post styles for a certain set of posts. For example the first three posts would be styled in it’s own way, the next four ...
0
votes
1answer
490 views

Insert html after certain amount of posts?

Is it possible after a certain amount of posts to close of a list and start a new one, like so... Particularly after 6 posts... <ul id="carousel"> <li> <ul class="inner-items">...
0
votes
1answer
524 views

Network wide post count (WP Multisite)

I'm trying to show the total amount of posts of my WordPress Multisite. For that I'm using the following code, which worked at the beginning. So I guess that there's something wrong with the ...