How to select posts from certain category with MySQL?
Hey everyone. I’m trying to count the amount of posts from a certain category by one author to display on the author.php page. However, I don’t know which query to use for that.
<?php $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'") ?>
What do I add to only display posts from, say, category ID 3?
- The topic ‘How to select posts from certain category with MySQL?’ is closed to new replies.