0
<?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?

1 Answer 1

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 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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