Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [count]

The tag has no usage guidance.

0
votes
2answers
36 views

Get post number both in the loop and in the post

I have a post type that is essentially a photography zine. I want each post to display in the archive page as an "issue" with a number associated, from oldest to newest. The first issue would be "...
0
votes
1answer
13 views

Display post count on archive page in reverse order

I'm displaying some posts and I want each of them to display a post number. The first post being number 1, the most recent post being 10 (let's say there's 10 posts.) I'm currently using <?php ...
0
votes
1answer
23 views

How can I count ACF sub_field with a certain value

I have a sub field that have several different values. What I'm trying to do is count the number of rows if they're equal to Mayor. So my code looks like this: if( have_rows('candidates') ): ...
0
votes
1answer
24 views

How to count posts in tags within time limit

When we list tags we can get the count and even sort by count like this: $tags = get_tags([ 'orderby' => 'count', 'order' => 'DESC', 'include' => $term_ids, ]); But how can we ...
0
votes
1answer
72 views

How do I insert a <div> after every 5 posts in a WordPress Loop that infinitely loads posts?

So I have a WPQuery loop set up that works great and uses and infinite scroll to keep loading posts in batches of 10 posts. What I would like to do is insert a <div> after every 5th post in the ...
0
votes
0answers
18 views

Count posts associated with another post type

I have two custom post types in Wordpress: Events and Venues. I need to count the number of Events associated with the individual venues and have the counts displayed in a column on the Venues page in ...
0
votes
2answers
40 views

What is the best way to do this? [closed]

<select name="select-city" onchange="location = this.value;"> <option value="">Select a post to read</option> <?php if ( is_user_logged_in() ): global $current_user; ...
1
vote
1answer
116 views

Warning: sizeof (): Parameter must be an array or an object that implements Countable, On products pages

I have a WooCommerce WordPress Theme installed. I'm getting an error that public users can see, So I need to fix it ASAP. The error is shown on all products pages, Here is the error: Warning: ...
0
votes
1answer
37 views

How to count posts with specific arguments

I'm wondering how I can request the amount of posts by passing certain arguments (you could see this as part of a "query"). See the example below. $args = [ "numberposts" => -1, "...
1
vote
1answer
10 views

Get count of custom post tags

I am trying to get the count of custom post tags gd_place_tags. But I just get the value "0" back. function tag_count( $tagatts ) { $tagatts = get_terms( array('taxonomy' => '...
0
votes
2answers
32 views

Search Count Wordpress Theme

I have a code that displays results for search but, I need it to include the count not just keyword searched <h1 class="font-thin h2 m-b"> <?php printf( esc_html__( 'Search Results for: %s',...
1
vote
0answers
15 views

WP users page doesn't show users count by role

I'm running a wp site which have 70.000 users imported from an old vbulletin forum. Everything works well except for an issue I have on the users page in the backend. As you can see in the attached ...
0
votes
0answers
18 views

How Can I add show_post_count in get_archives_link?

How can I show archive's post count in an customized html output for archive? //Change Archive List HTML function change_archives_output($link_html, $url, $text, $format, $before, $after) { if ('...
0
votes
0answers
9 views

How to get terms by posts total comment count?

Is any way to make it? Just calculate posts comments total number and order terms by this. Is it possible? $termArgs = array( 'taxonomy' => 'category', 'hide_empty' => 1, 'orderby'...
1
vote
1answer
92 views

How to count rows of table in the_content()

In fact, every post in custom post type contains just a table that has several different rows. Every row is important, so we want to count them by a function and I think it is possible by counting <...
1
vote
0answers
31 views

Get count of terms with a post and another taxonomy term?

How do I count the number of taxonomy terms which have both a) an associated post and b) where that post also has an associated term from another taxonomy? Specifically, I have... Custom post type "...
0
votes
3answers
62 views

How to count total words for posts published by one author?

How can I get a total word count of one author's posts? Thanks. To be more clear, I wanna show the total word count in the author archive page, preferably using code.
0
votes
1answer
249 views

How to update incorrect post count in taxonomy?

I have imported a large amount of content using WPAllImport, all to a custom post type called "article" ("Articles") and all organised by a custom taxonomy type called "source" ("Sources"). However, ...
-3
votes
1answer
42 views

Count div with class (.length) only shows 0 [closed]

I want to count a div with a class (it's a class from the Plugin Revolution Slider) div.tp-tab This class exists 3 times! I have tried this: <script type="text/javascript"> jQuery(document)....
0
votes
1answer
32 views

Count Number of Posts in Taxonomy Term in Last 24 Hours

if anyone could help it would be greatly appreciated, been trying to get this done on and off for a long time and just can't get there. I am using the function below in a loop to count posts within ...
1
vote
0answers
62 views

Apply an Incremental Counter in an Array Function

I'm attempting to incorporate an incremental counter inside an array function, that is, in turn, inside the post's while loop. However, I am only able to get it to count to 1. This is what I ...
3
votes
2answers
51 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; ...
0
votes
0answers
241 views

How to get the count of Following and Followers for users

I'm using a plugin "Favorite-Authors" and the plugin owner stopped updating, and i just want to get the followers count of who followed me or the others, I can get the following count by using the ...
-1
votes
1answer
76 views

How to get the total count of Favorite/Favorited authors

I'm trying to get the total favorite/Favorited count for each user, i'm planning to add the counts into author.php to show how many authors Favorited him and how many he favorite others, this the ...
0
votes
1answer
179 views

Display Custom Post Category Count & WordPress Category Count Using Shortcode

I am trying to create a shortcode to display the posts count of a custom post type as well as standard post categories. I have successfully done this using this code snippet from a similar post: // ...
0
votes
1answer
50 views

Counting Posts by Category

I am trying to learn WP Query but finding it a little hard going. I have Posts created from a Forum Plugin (wps_forum_post) and I wish to display counts in descending order based on their selected ...
1
vote
1answer
18 views

Remove ID page from wp_count

I'm try to create a pages counter excluding certain ID pages but the code don't work. I'm using this code. How can I fix it? Thanks. <?php $count_pages = wp_count_posts('page'); echo "$...
0
votes
1answer
791 views

Shortcode with product catgory counter

I would like to create a custom shortcode that count individually product-categories in Woocomerce but I haven't found any code on net. I need somethink like: [counter product-category="example"] ...
0
votes
1answer
263 views

number of posts with “Load More”

I am using the plugin Ajax Load More to query posts and have a filter system to thin out the posts in the loop. I am trying to add a counter that will say "Your search returned X amount of posts" ...
0
votes
1answer
26 views

I have a problem with displaying children pages of custom post type

All I need is to get a number of children pages of a custom post type This is my query: $args = array( 'post_parent' => $post->ID, 'post_type' => 'all_products', 'orderby' => '...
0
votes
1answer
18 views

Sort posts by clicks on download button

In my website each post has a download button for a certain asset. I want to be able to sort my posts by how many times an asset has been downloaded (or, in other words, how many times the download ...
1
vote
1answer
34 views

How can I get global $post to work for CPT and update user?

Ive created a custom field in my user_meta which now I want to update the count each time one the user posts are viewed. Ive got this which works great for standard wordpress posts. However I need it ...
0
votes
1answer
54 views

Get the total Author Favorited posts

I am using the plugin https://favoriteposts.com. To be a little clearer I have posts on my site that have a favourite count as a meta value. I want to get the total favourite count of all posts ...
0
votes
0answers
80 views

Author.php Page views counter

Wondering if some one can help me. Im looking for a page counter for the author.php Ive got about 300 authors on the site and they would like a counter to show them how many times there "profiles" ...
1
vote
3answers
32 views

Count total number across post types

I am using this code to count number of posts for one custom post type. What's the best way to change this to sum up together 3 different custom post types? function get_all_them_ven_posts(){ $...
0
votes
1answer
26 views

Modify the category post counting function

I have a little problem with category post counting. Basically, I made a custom post type, say ‘movie’, using "custom type post UI" plugin, and linked it with built-in category. Also, I am using the ...
0
votes
1answer
22 views

ho can I get the number of the current post instead of the post id?

let say i have these post: firstpost secondpost thirdpost fourthpost if th currentt post is secondpost, I need to return the nr: 2, if the current post is fourthpost, I need to get the nr: 4, but ...
0
votes
1answer
35 views

Set Pagination count according to post count

i have created a php template for a page and displaying posts from my custom post type, but i am skiping posts according to the followed condition. so this is my page template code. $paged = ( ...
0
votes
1answer
64 views

get the count of table rows

What is wrong in my code? It doesn't get the count but it is inserting into the database. function r_rate_recipe() { global $wpdb; $output = array('status' => 1); $post_id = absint($...
0
votes
0answers
853 views

How to get meta key value count in woocommerce orders?

Hi I am working on woocommerce I have added custom fields for orders which is agent name , each order has assigned with agent. I want to find agent name with its total order count. I have created ...
1
vote
1answer
72 views

Conditional based on number of specific custom taxonomy terms in archive.php

I struggling to find a way to count and conditionally apply // do stuff based upon the number of terms of a specific taxonomy(ABC) in archive.php... All I have is this below but it counts all the ...
0
votes
1answer
54 views

Problem with displaying HTML content after in_array [closed]

I'm trying to create layout based on this question and answer. First of all, it took me ages to understand why if there's only one post in the category, it's not showing up - so I found out that ...
-1
votes
1answer
118 views

Click Count on Download a File

i have website with woocommerce for digital download. I make all free for download, and this my code for download the file: $downloads = $product->get_files(); foreach( $downloads as $key => $...
0
votes
0answers
10 views

how to add the number of each publication (article page product … and other) in the wordpress admin dashboard

I would like to know how can add a column in the administration of each page ... or other. by a pluguin or a hook. help me please it's urgent. if you did not understand me contact me I explain you.
0
votes
1answer
486 views

Implementation to count page visits of unique visitors based on a cookie

It sounds so simple, but I cannot seem to find a simple way to simply count the number of unique visitors of a single page (e.g. by using a short code on that page for a counter or a full PHP ...
0
votes
2answers
497 views

custom post type category count shortcode

I'd like to create a shortcode that would display the post count for a specific category within a custom post type. I've been trying to alter the code below but need some help. Could anyone let me ...
0
votes
1answer
37 views

Display number of post published every day

how can I display the number of posts published daily/weekly ? I don't care about caching, i can even disable it. Obviously if there is a cached way it would be more helpful.
0
votes
1answer
137 views

how to count the current posts terms

Hi i'm trying to figure out how to count the number of terms for the current post, i've tried using wp_get_object_terms() and <?php $title = get_post($post->ID); $numTerms = wp_count_terms( $...
1
vote
2answers
1k views

How can I count post views of REST API calls and update them in an ACF field?

I don't know if I've complicated things a bit, so I'll explain things from the top. I have a set up with a custom post type (news), which is exposed via the REST API. The main endpoint (/wp-json/wp/v2/...
0
votes
3answers
53 views

Counting posts with argument without retrieving the posts

I have a quite extensive database, 30000+ items, and using this: $args = array( 'posts_per_page' => -1, 'post_type' => 'books', 's' => $s ); $post_counts = ...