Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.
<?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 =     photoshop_tutorial' AND post_status = 'publish'");    
?>

<p>Post Count: <?php echo $post_count; ?></p>

I've tried with this codes & it shows the whole photoshop_tutorial posts count, but what I want is to display for individual author's posts, because I want to add it in author page.

For example:

Smith posted <?php $post_count; ?> photoshop tutorials

How can I do that?

share|improve this question

1 Answer 1

Did you tried fetching the requested posts with WP_Query?

$posts = new WP_Query();
$posts->query( array(
    'posts_per_page' => -1,
    'author' => $curauth->ID,
    'post_type' => 'photoshop_tutorial'
) );

$post_count = sizeof( $posts->posts );
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.