Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [count]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
15 views

How to get total posts count for each date?

function test_dashboard_content() { $args = array( 'posts_per_page' => -1, 'post_type' => array( 'post', 'page' ), 'post_status' => 'publish', 'date_query' => array( 'after' => '...
WPdummy's user avatar
  • 23
0 votes
1 answer
21 views

How to make FSE's query loop to order by comments number?

I apologise deeply if this topic already been answered here in the past. I have searched for an answer and couldn't find. The question is regarding Gutenberg, FSE editor, block theme: is it possible ...
neoswf's user avatar
  • 125
0 votes
1 answer
41 views

Hide load more button if no more post in selected category

I have built a ajax post loading program in wordpress where i load post depending on category and current post type. ive got it all working except hiding the load more button if no more post. ive been ...
Beep's user avatar
  • 29
0 votes
1 answer
69 views

Can I count every article following extracted meta value?

I can show all value in certain meta key(species1 and species2) by my code below. It shows like this. $species[]contains many kinds of bird species. Crow Eagle Crane Pigeon... Now, I like to count ...
cwhiro's user avatar
  • 25
0 votes
2 answers
60 views

Adding count also to parent categories

In this moment I have a code to show the count on categories, the problem is that the parent categories display always 0, insted of the sum of posts in children categories function ...
Andrea Sacconi's user avatar
0 votes
1 answer
35 views

Adding a posts count in archive pages

In the category page I need assistance the title is the resort “Lignano Sabbiadoro” , I’d like to display the number of posts (apartments) for this category, maybe in a different color, i.e: Lignano ...
Andrea Sacconi's user avatar
0 votes
1 answer
167 views

How do i display the number of images on the "post screen"

I need help displaying the number of images in a POST on the post edit screen, For example if 5 images are attached to article A, and they are now reused on article C it should display the total ...
iamkingsleyf's user avatar
0 votes
1 answer
212 views

Count the number of matching post names in foreach loop

I have a simple foreach loop that outputs an ordered list from a CPT 'post_subscribers' and an associated meta key called 'project'. $theposts = get_posts( array( 'post_type' => '...
dekkyd's user avatar
  • 7
1 vote
1 answer
26 views

Complex Custom Loop with Includes

The Problem I have a complex loop designed for showcasing my portfolio. Here is the criteria: Portfolio is powered by a custom post type called PORTFOLIO Each post will be assigned a class of either '...
Sabotawsh's user avatar
0 votes
1 answer
110 views

Count words for all posts by all authors

So I got this code from another query and it works for one single post. However, I want to show the total words of all the published posts by all authors. How do I modify this or is there a wp ...
Elaine Byene's user avatar
1 vote
1 answer
69 views

How do I count the number of pages a user has seen on my site, and force them to log in after a certain amount

I'm looking to write a little function that counts how many pages the user has clicked through in this section. When it gets to a certain amount, I want to prompt them to log in and prevent them from ...
DJZEEGLER's user avatar
  • 119
0 votes
1 answer
397 views

How to cache the results of a query and display the cached results

I have a website centered around music. I have 3 main post types- 'Artist', 'Release', and 'Version'. There are 4 types of 'Version'- album, single, video, misc. Artist is parent of Release. (artist ...
DJZEEGLER's user avatar
  • 119
3 votes
1 answer
450 views

Fastest way of counting posts of a custom post type in a specific taxonomy term?

I know this kind of question is legion but I have read through all related topics and I can't find a satisfying solution. What I want to achieve is simple: on my taxonomy (author) term archive page I ...
Julien G's user avatar
0 votes
0 answers
25 views

Count the total views of all user posts published

I have 1 essential questions I want to count the total views of all posts published by a user (login user). for example show: total view of your all posts: 485 Is there a way to do this? Can you help ...
mostafa ajdadi's user avatar
0 votes
1 answer
163 views

ACF: How to query for a given value count of an array like field? (e.g.: How many rows has a `flexible_content` field?)

How can I write a WordPress meta query that gives me an array of users/posts that have a given amount of entries in a custom field that stores multiple values? Something like SQL COUNT(), but for the ...
David Wolf's user avatar
0 votes
0 answers
41 views

Show the number of the post

I'd like to show the Number of the post near the post in a category. It's simpler to explain with a drawing than with words: My first solution was a simple counter inside the loop, but it doesn't ...
gb_factory's user avatar
-1 votes
1 answer
41 views

How to calculate posts number? [closed]

I want to achieve something like this: foreach ( $posts as $post ) { if ( $a = $b ) ) { // if true +1 to the result; } else { // if not true -2 to the result; } } echo '...
Avigo's user avatar
  • 37
0 votes
0 answers
46 views

Allow a specific user role I have created to only upload one image to his media library

Hello guys I was following this article but the code doesn't seem to do anything. The last one by Maruti Mohanty is doing something , it doesn't allow any files to upload with an error. Set a maximum ...
Johnda's user avatar
  • 1
0 votes
1 answer
52 views

Counting instances of words in the results of a post query

I'm way over my head with this one and wonder if anyone can shine a light on where I'm going wrong. I am grabbing some authormeta for the resulting posts of a query, and I want to tally up the number ...
Lorn Waterfield's user avatar
0 votes
0 answers
32 views

Query posts by post type, author and post meta

Bit of an awkward one here, and there may not be a solutions within current WP core. Basically I have a CPT called "connection" with a custom meta field called "outcome" which ...
Lorn Waterfield's user avatar
0 votes
1 answer
48 views

display post count in archive page that have relation with another taxonomy term

This topic has been ask in Stackexchange many times. But most of question unanswered or has incomplete answer. My custom post type "Product" and two different taxonomy "Sectors" ...
Teymur Abbasov's user avatar
0 votes
2 answers
285 views

Author post count in category

I want to count authors post count in a specific category. How do i do that? I have red this thread here but still can't fiure it out. Count number of posts by author in a category Edit: This is what ...
ANdy's user avatar
  • 47
0 votes
1 answer
81 views

Set post title font size automatically according to number of words in post title

When creating a post, i would like for it to check if the post title i set is longer than let's say 15 characters, if it is then i want to change the font size to a smaller size. I am using the Enfold ...
Sander105's user avatar
0 votes
1 answer
22 views

If x comments in a post move post to category y

If a post has 0 comments do nothing. If a post has 1 comment move the post to category 1. If a post has 2 comments move the post to cayegory 2. If a post has 3 comments or more move to category x.
ANdy's user avatar
  • 47
0 votes
1 answer
1k views

List all categories and count number of posts within based on custom date

I used this solution to count number of posts for each category (list). The counting is based on date post event (only from today's date). I got nothing var_dump show result of new WP_Query . but $...
imagIne's user avatar
  • 83
1 vote
0 answers
98 views

How to use wp_query to post count by search term > group post count by date > convert to json. (ex. result 12-21-2020 - 343)

Im trying to create a graph that displays count of post per day and display it on the search result page. Search Example. User searches with the search term "football". The search result ...
Cavamondo's user avatar
0 votes
1 answer
997 views

Like and Dislike Buttons on Post with Counter - Only allow one click per post per user session

Working on a "Like" vs "Dislike" for blog post in WordPress. While all is working fine, the intention here is to make it work for guests and logged in users, but more importantly; ...
Dominic Herold's user avatar
0 votes
1 answer
176 views

Count tags for a specific category

So I have a simple code that gets the tags and counts them. How would I limit this code to count how many posts are tagged but only include those posts that belong to a specific category? Right now, ...
Dan's user avatar
  • 43
0 votes
1 answer
91 views

how to count click tab menu and insert to database

I have a tab menu with the following structure, clicking on which will add an active class to the li element Now I need to count the number of clicks of each tab separately and more importantly save (...
Sinapars's user avatar
0 votes
0 answers
191 views

Display category filters for custom post type when category is shared by multiple post types

I already have a solution to this problem but I'm wondering if there's a more efficient way to do it. I have a custom post type called "galleries" that uses the same taxonomy as blog posts. ...
Jake1293's user avatar
0 votes
3 answers
63 views

Show the amount of posts in a tag in a specific category has

I am creating a page template in Wordpress that displays multiple tags that are in a particular category. I have this working, but now I want to have the number of posts within each tag that is ...
RLM's user avatar
  • 247
0 votes
0 answers
36 views

How can I show how much water got saved on this order (making use of the number of items bought) on a thank-you-page?

More detailed: I'd like to use the the number of items which were bought by somebody and multiplicate it with a number, to show how much water somebody saved. function random_message(){ $...
Chrizzly's user avatar
0 votes
2 answers
185 views

check the first login for specific roles

Based on this answer i created a small functionality for users that are logging in for the first 3 times to make some elements classes use css animation. What i am trying to do is to adjust this code ...
Honoluluman's user avatar
0 votes
1 answer
110 views

php loop error for count posts in category

I have multiple categories on my wordpress page and each of the categories has 1 to n subcategories. If a subcategory contains only 1 single post I would love to display an excerpt of this post, ...
JonSnow's user avatar
  • 115
0 votes
2 answers
1k views

How to display total user count by specific role in WordPress as statistics?

i want to display in my Home page total user count by specific role in WordPress as statistics I already created Role (subscriber, contributor) and i want to show the total users for each of those ...
Adnan Omar's user avatar
0 votes
2 answers
349 views

How do I find the count of the current post?

Let's say my custom post type is 'story'. I've got 20 stories published on my site. So each post becomes: 'story 1', 'story 2', ... 'story 20'. Thus, first post is 'story 1', and last post is 'story ...
Ash's user avatar
  • 3
0 votes
1 answer
139 views

Count several post tags

This maybe should be posted on a php forum, but since it's WordPress related, I'm giving it a try here.. With this code, I'll get the total count of posts work a certain tag; $term = get_term_by('...
JoBe's user avatar
  • 171
0 votes
2 answers
1k views

Count how many posts have a specified tag AND category

I know how to count how many posts has a certain tag, or category For example: $term_slug = 'some-post-tag'; $term = get_term_by('slug', $term_slug, $post_tag); echo $term->count; BUT! Is there ...
JoBe's user avatar
  • 171
0 votes
2 answers
180 views

order posts by a secondary query that counts items

i'm working on a music plugin. It uses a custom table tracklist_items to store every tracks of a playlist; which has a structure like this : |id| |track_id| |tracklist_id| |order| |time| So if I ...
gordie's user avatar
  • 492
2 votes
0 answers
60 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 $...
Robert Andrews's user avatar
1 vote
0 answers
1k views

Pagination is not working properly in Product Category/Tag pages

I have a store with several products. Pagination works fine on the main shop page. But when I open a separate product category or product tag pages, in some of them pagination not working as expected....
rohit1113's user avatar
0 votes
1 answer
435 views

Author comment count in author page

hi i want to show author comment count in author page. this code can display current user comment count but i dont want current user i need any user please help me /* user commnet count */ ...
Gidromasservis QSC's user avatar
0 votes
2 answers
366 views

In WordPress, how do I get the number of posts next to single_cat_title(''); in the category.php file?

In WordPress, how do I get the number of posts next to <?php single_cat_title(''); ?> in the category.php file? <h1><?php single_cat_title(''); ?> (<?php ????code to count number ...
Glen Charles Rowell's user avatar
1 vote
1 answer
1k views

Adding country tags automatically

I want to show country flags on post cards.My plan is showing flag icons with below code: <img src="/icons/<?php echo $tagName; ?>.png" /> However I dont know how can I add country tags ...
Faruk rıza's user avatar
0 votes
0 answers
583 views

get_queried_object not work in taxonomy page

I am trying to display post count by month of current custom taxonomy in custom taxonomy page. but it display total count by month <?php $post_type = "tesekkur"; $posts = get_queried_object()->...
Raminer's user avatar
  • 33
0 votes
1 answer
48 views

I am trying to get cutom post cout by month of current taxonmy term

Hi please help me how can i display custom post count by month like this at current taxonomy page. **i have been trying to solve this problem aready 2 weeks. ** December 0 January 0 February 0 ...
Raminer's user avatar
  • 33
1 vote
0 answers
28 views

Post count by month of taxonmy term

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
Raminer's user avatar
  • 33
1 vote
0 answers
27 views

There any way to get de percentage of number of post by user and category?

This is the thing, Id like to get the % of number of posts from a specific user and category, additionally choosing from 'n' last days, or get for 'n' posts. Example: A: User 2 have a 10% of total ...
Velask's user avatar
  • 11
2 votes
0 answers
96 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 ...
Raminer's user avatar
  • 33
0 votes
0 answers
557 views

Get user count based on multiple meta key values?

I am trying to count all of the users meeting multiple criteria. I have tried so many different things and cannot get it to work. Any help is much appreciated. Thank you. add_shortcode('...
Michael's user avatar
  • 281

1
2 3 4 5
7