Questions tagged [count]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
3answers
2k views

Echo the number of posts being displayed

I had this code working as I needed it to...but now I need to add a post count where the "____" is, beside "posters", so I can manipulate the css depending on how many posters are showing, for example:...
0
votes
1answer
2k views

Divide post content in three columns

Is it possible to split the_content() into three equal size columns? I have tried to achive that by getting this code which I found here <?php $content = get_the_content(); $...
0
votes
1answer
448 views

User count only for role frontend vendor

i use the following code for count the authors $count_posts = wp_count_posts( 'download' ); echo 'Published eBook (' . $count_posts->publish . ')'; echo ' '; global $wpdb; $...
1
vote
1answer
252 views

Modify text after post count

On my Archives page, I list categories with post counts. I've modified the post count by removing the parentheses, wrapping them in a span that floats them to the right, and putting the word "Entries" ...
0
votes
0answers
1k views

Counting custom post type with wp_count_posts returns an empty object

For some reason the wp_counts_posts function returns an empty object if I use my custom post type's name in the function's parameter. The var_dump is: object(stdClass)#93 (0) { } The name of my cpt ...
0
votes
1answer
142 views

How to Define Custom Number of Items in Comment Feed

Seeking a hook or code to override the Reading-Settings value for Syndication feeds show XXX items specifically for the comment feeds. Ideally I'd want to roll into a plugin I can network activate ...
3
votes
2answers
13k 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. ...
0
votes
1answer
703 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, ...
5
votes
4answers
10k 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 ...
1
vote
3answers
20k 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 ...
0
votes
2answers
163 views

Taxonomy term count

I have a custom post type called "RESOURCES" which I used to create a directory of resources on my website. This CPT has the taxonomy called "PRICES". There are three terms free free trial premium ...
0
votes
1answer
620 views

Count images in post then add class if just one

I'm trying to add a function to my site that will count the number of images attached to a post, and if only one, to add a class to either that <img> or to the containing <a>. I think I'm ...
0
votes
2answers
1k views

How do I count columns on a custom WPDB query?

How would I count the columns of a custom WPDB query? This does work although I need a different kind of output: $sql_assoc = "SELECT * FROM test"; $num_cols = count((array) current($sql_assoc)); ...
0
votes
1answer
5k views

Order terms by count - missing terms

I have this problem: I'm using get_terms with ordering by count. And some terms are missing - I have no idea why, there is no exlude, or hide posts or anything like this. What is wrong? Here is the ...
10
votes
2answers
40k 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') ); ...
0
votes
1answer
446 views

$count_posts->draft & published

Currently our portfolio is stacking up a lot and want to show a few projects less instead of showing all. Still, I'd like to show an indication how many projects we did in total. Currently I have the ...
1
vote
1answer
6k views

Display posts count in front of the tag, for each tag

I needed to list all existing tags so I have some code that does it. Now I would like to put the count (the number of posts the tag is associated with) in front the tag like in the example given below....
1
vote
2answers
2k views

Count all comments of a custom post type

I know how to count comment per post, user and in total but i am having problems getting the total amount of comments post in a specific post type. I guess i can loop trough all the posts and count ...
1
vote
3answers
568 views

right_now_content_table_end function not working?

I noticed recently my custom counts for custom post types are not showing on the dashboard. Im using this function: right_now_content_table_end It worked well before, Im not sure when it stopped ...
2
votes
1answer
20k 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 ...
0
votes
2answers
397 views

Issues with the excerpt (wordcount/HTML/images)

Struggling here with the excerpt and options for it. (NOT looking for a plugin and not extracting from the content, we add seperate excerpt content) We want to have an excerpt limited to a max. ...
1
vote
1answer
1k views

How to hide first gallery for every post?

I'm using galleries for attaching images, so the very first gallery for every post is used to generate a slider and nothing more. That's why I don't want to see it in post's conent. Let's say I have a ...
0
votes
1answer
824 views

Display count of new members registered today [closed]

I would like to display the registered members count for today in BuddyPress. Something like: 20 new members registered today I have no clue where to start, so I cannot provide any code yet :(
0
votes
1answer
361 views

Add a minimum word count to Excerpt (and how to force Excerpt as a rule for WyPiekacz)

How do I add a minimum word count to the Excerpt field before the post can be sent for pending review? I want to require content in the Excerpt field. And also, how do I add the Excerpt field as a ...
0
votes
1answer
1k views

Count post views in loop

I'm trying to show the post views for every post on a blog page (so in a loop). I tried it with the following code in the functions.php: // function to count views. function setAndViewPostViews($...
1
vote
1answer
1k views

Wordpress count child posts of each parent custom post type and use in json array for google maps jquery plugin

So i have been looking for a couple of days now and cant find a solution to this anywhere. It is a fairly bespoke request from a client... I am using a jQuery google maps plugin to add markers for ...
0
votes
1answer
174 views

Category count but only if category has at least one post

I need to display the number of categories which I can do with this... <?php echo $num_cats = wp_count_terms('category'); ?> ...but I only want it to count categories that have at least one ...
2
votes
2answers
3k 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 ...
0
votes
1answer
1k views

Display amount of pending posts in back/front end

I want to display the total amount of pending posts that my site has. My site is a single site, not a network. I am looking to echo that count in the back-end (a custom plugin page) and in the front-...
0
votes
0answers
385 views

How to get the count for each taxonomy term

I know it is $term[0]->count; However, my terms are placed in the custom menu plugin. My terms are currently structured as Parent Child Parent Child How do I append the term count of each ...
1
vote
0answers
318 views

Limit image upload

I'm trying to limit the amount of files a user can upload through the wp gallery, and i've found the following filter from this link Limit image upload to one and disable audio, video and other ...
1
vote
1answer
69 views

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

Getting comment count per post not working

I have this function: <?php $popular = new WP_Query('orderby=comment_count&posts_per_page=5'); ?> <?php while ($popular->have_posts()) : $popular->the_post(); ?> <li&...
4
votes
1answer
4k 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 ...
0
votes
1answer
551 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 ...
2
votes
1answer
116 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 ...
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 ...
0
votes
2answers
103 views

Counting posts by certain author with custom taxonomy

I'm using this code to display the last three posts of a custom taxonomy ('special') by a certain author: <?php query_posts( array( 'taxo' => 'special', 'showposts' => 3, 'author' => 2 ) )...
1
vote
1answer
1k views

Getting the current post number / make posts increment

I'm creating a site similar to http://thegreatdiscontent.com/ in that there's a bunch of posts on the site, and only one post gets shown per page. I want to add a counter that says something like: "...
4
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. ...
0
votes
1answer
151 views

Post loop count is not in order

I am using custom post type. But on landing page Count of post loop is not in order <?php $loop = new WP_Query( array( 'post_type' => 'focus-areas' ,'get' => 'all') ); ?> <?...
0
votes
1answer
728 views

Count post + add number =

I'm having problems with counting posts of a custom post type called 'projects' and like to add a number to the count. We did some stuff which can't be shown in our portfolio but would like to add ...
1
vote
1answer
130 views

Admin option sidebar count

I need to add a count number to a option menu item in the admin sidebar. How is this done? I found a similar post: Modifying admin sidebar contents to show pending posts indicator
1
vote
1answer
2k views

User's total comment count excluding comments on their own posts

I'm currently working on a plugin that I hinted at here and so far I have managed to code everything, only missing one piece of the puzzle. This is how I get the total comment count for the ...
0
votes
1answer
383 views

How to add a post counter to the list of custom taxonomy terms?

I am using the below code to display the list (radio buttons) of terms that are currently used by existing custom post type posts: $args = array( 'taxonomy' => 'typ', 'post_type' => '...
0
votes
1answer
76 views

How many members have made comments approved for an article?

Good afternoon. Please, I would like to have a function that calculates for each post displayed (one by one), not how many comments, but how many are the authors of the comments for the post viewed at ...
1
vote
2answers
6k 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 > <...
3
votes
1answer
825 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 = ...
0
votes
1answer
800 views

Count user posts and store the number for later use

I want to count author posts and store this number for later use even if some of the posts have been deleted in the meantime. $rows = $wpdb->get_results( $wpdb->prepare( "SELECT post_status, ...
0
votes
2answers
318 views

How to do simple addition to increase favorites count of my wordpress posts

I have a code in my functions.php that gives me a count of how many favorites a post has got. function wpfp_get_current_count() { global $wpdb; $current_post = get_the_ID(); $query = "SELECT post_id,...

1
3 4
5
6 7