Count several custom post_types of an specific author in Author.php
-
Hi!
I am a newbie on wordpress and php and I have my mind blowing because I am trying to find a way to compile this code that I found here…
<?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>
My goal is to show the count of published posts foreach custom post_type in author.php and I found a way to do it but this is not the right way. You can see my code here https://pastebin.com/6cSxs4th.
How can I compile this?
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Count several custom post_types of an specific author in Author.php’ is closed to new replies.