Questions tagged [count]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
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 ...
0
votes
1answer
966 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
378 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
308 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
65 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
6k 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
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 ...
0
votes
1answer
508 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
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 ...
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
91 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
883 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: "...
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. ...
0
votes
1answer
148 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
622 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
95 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
1k 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
378 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
72 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
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 > <...
3
votes
1answer
708 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
616 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
258 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,...
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 = $...
4
votes
1answer
552 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 ...
1
vote
1answer
1k views

How we count the user draft posts

I am trying to use the total posts count currently i am using the this query $args=array( 'author' => $userID, 'post_type' => 'post', 'post_status' => $poststatus, 'posts_per_page' => 212 ...
5
votes
7answers
8k 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) ...
0
votes
1answer
803 views

Display custom post counts for author , not default posts

<?php global $wp_query; $curauth = $wp_query->get_queried_object(); $post_count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '" . $curauth->ID . "'...
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 $...
0
votes
2answers
4k views

Count number of posts of current month

I am trying to echo the number of posts for the current month from all categories but it isnt working. <?php $month = date('m'); $year = date('Y'); $countposts = get_posts('post_type=post&year=...
-2
votes
1answer
5k views

post_count not working

I've fixed my initial problem but I'd like to know what I was doing wrong. <?php $args = array( 'post_type' => 'page', 'post__not_in' => array( $post->ID ), '...
1
vote
0answers
614 views

Word count not accurate - potential bug

My editors reported that there appears to be an issue with my word count on the post edit page. Testing this proved true, check the word count: This is affecting all posts, for instance, a post with ...
1
vote
1answer
2k views

Count posts by type including drafts and pending posts

I had this function that counts posts number by type (taken from wordpress codex) function count_user_posts_by_type($userid, $post_type) { global $wpdb; $where = get_posts_by_author_sql($...
0
votes
2answers
962 views

How can i count post from my post type taxonomy

How can i get the count for published post from my custom post type , from my taxonomy. I have Custom Post Type : trailers, Taxonomy : trailere-noi <?php $items = get_posts( array( '...
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 ...
0
votes
1answer
2k views

How can i count the post added in relationship field, theme display

How can i count the post added in relationship field. The relationship field is a plugin (http://www.advancedcustomfields.com/docs/field-types/relationship/) In my admin i have a MetaBox i create to ...
0
votes
1answer
2k views

Show ellipsis (…) only if the number of characters exceeds limit defined in substr

I'm limiting the number of characters in the title with substr. But even if the title is less than 50 characters, being shown the ellipsis (...). I would not display the ellipsis if the title does not ...
0
votes
1answer
143 views

Count posts published in one particular day: the lighter way

I would like to get just the number of posts published in one particular day. I'm using this code, but this retrieve lot of code: $day = date('Ymd'); $query01 = array('numberposts' => -1, '...
0
votes
4answers
998 views

How do I display an image before the first post of the loop when I'm using get_template_part?

I have used $count before, but never run into this problem. I cannot get it to work. I have limited php background, so please be patient with me! Here is the $count setup code: <?php $count = 0;...
1
vote
1answer
560 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
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
0answers
169 views

Get Number of total Parent Categories for Custom Taxonomy

I am running an artist feature blog where I do interview artists from different countries and post some travel stuff from different countries. I've set up a Custom Taxonomy called "Artist Name". This ...
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 ...
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,...
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' =&...
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.
0
votes
1answer
40 views

why the posts queried from sql is more than those showed on the page?

i am using WordPress multisite, the issue i face is that the posts queried from sql is more than those showed on the page, the details is as follows: mysql> select count(*) from wp_137_posts where ...
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; $...
0
votes
1answer
13k views

Best way to count visitors?

I want to count how many people visit my wordpress-website an want to know the following data: visitors per day/week/month/year (with history) which subpage/article attracts the most visitors Is ...
0
votes
1answer
583 views

How to get terms of not only the current cat but also of all its children

I'm modding a theme to use parent taxonomy terms instead of all taxonomy terms, now I've been able to only display the parents, but now I've run into a count problem. Basicly this is the code that ...