Quantcast
Channel: Topic Tag: MySQL | WordPress.org
Viewing all articles
Browse latest Browse all 5540

Swennet on "How to select posts from certain category with MySQL?"

$
0
0

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?


Viewing all articles
Browse latest Browse all 5540

Trending Articles