i found this code wordpress.org . This code would work in author template.
<?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 . "" AND post_type="post" AND post_status="publish"");
?>
<h2>Post Count: <?php echo $post_count; ?></h2>
But if you wish to use it somewhere else then replace $curauth->ID
with author id and post
with the post type you want
it should work .
All the best
Related Posts:
- C++ – how to find the length of an integer
- How can I make a PHP counter?
- Counting the posts of a loop (WP_Query)?
- Category and children post count
- Hide the post count behind Post Views (Remove All, Published and Trashed) in Custom Post Type
- How to display 2 equal columns of li based on the count of items in wp_nav_menu divided by 2?
- Show weekly posts statistic in WordPress
- Increasing post view count automatically [duplicate]
- Count number of posts by author in a category
- How we count the user draft posts
- What is the best way to count and display the number of posts?
- Get count of terms with a post and another taxonomy term?
- Get Gravity Forms field values and count how many? [closed]
- Show ellipsis (…) only if the number of characters exceeds limit defined in substr
- Get total views of all posts by author
- Count post + add number =
- How to do simple addition to increase favorites count of my wordpress posts
- Count posts published in one particular day: the lighter way
- What is the best way to do this? [closed]
- Search Count WordPress Theme
- How to read out the excerpt length (for if-condition)
- $count_posts->draft & published
- CountPost WordPress Custom Taxonomy
- get the count of table rows
- How to calculate posts number? [closed]
- How make animation increase of number
- Having problems getting the number of plays in a WordPress Playlist from an audio file
- How to show the amount of post that have on the site?
- How to count the occurrence of certain item in an ndarray?
- Calculate average in java
- Counting the occurrences / frequency of array elements
- How to count the number of files in a directory using Python
- select count(*) from table of mysql in php
- Count & Display Database Queries
- Count posts within a custom post type and specific taxonomy and terms?
- WP 3.5 and Galleries – how to count images?
- Count post that have specific meta value
- Count posts in category including child categories
- Count user posts by type and date
- Count custom post types with a specific meta value
- Problem with get_posts, tax_query and counting the number of posts
- Network wide post count (WP Multisite)
- Specific Loop For 2 Within Each
- Get count of custom post type created by current user
- How to count get_users query?
- Count number of published posts by type
- Total Word Count For Posts And Comments By One Author
- How to trace/fix false $term->count, rogue term relationships?
- Double count view in archive.php
- Count to how many categories a post belongs to
- count_many_users_posts except current logged in user?
- Woocoomerce product category count including subcategories
- Count search results in heading
- How to hide first gallery for every post?
- Display Published Posts Count for Certain Time Period
- Apply an Incremental Counter in an Array Function
- Remove ID page from wp_count
- Conditional based on number of specific custom taxonomy terms in archive.php
- Display Notification Bar on Header on Certain Post Count
- Count number of posts of current month
- Howto show comment count by post in post?
- Best way to count visitors?
- How to get terms of not only the current cat but also of all its children
- how to count click tab menu and insert to database
- Count several post tags
- In WordPress, how do I get the number of posts next to single_cat_title(”); in the category.php file?
- How to count total words for posts published by one author?
- Sort posts by clicks on download button
- Trying to add a class to post links
- WordPress Count posts within a custom post type
- (get_post_ancestors == 2) is returning true on 1 as well?
- Search result count not matching actual result
- Counting posts by certain author with custom taxonomy
- why the posts queried from sql is more than those showed on the page?
- How to cache the results of a query and display the cached results
- Count the total views of all user posts published
- Count Post and Page Views based on meta_value Using Shortcode in Dashboard Widget
- ACF: How to query for a given value count of an array like field? (e.g.: How many rows has a `flexible_content` field?)
- Counting instances of words in the results of a post query
- Query posts by post type, author and post meta
- Display category filters for custom post type when category is shared by multiple post types
- check the first login for specific roles
- How to display total user count by specific role in WordPress as statistics?
- How to count items of meta query?
- Get queried object for custom post type count
- Count tags for current post and save into custom meta field (and update it on post edit)
- Warning: count(): syntax problem of the count () function
- Sorting Tag Cloud by Popularity
- Reverse count page view and show on other page
- Counting Posts by Category
- Click Count on Download a File
- Columns depending on posts count
- counting post from a wp-query using sticky_post
- Custom Looping of WordPress Posts
- How to limit the number of posts a user can view based on status
- Category count but only if category has at least one post
- How to get the count for each taxonomy term
- post_count not working
- How to export tag counts to excel?
- Count div with class (.length) only shows 0 [closed]