You can also use the following query for getting the results if you have author_id
, post_status
and cat_id
with you.
global $wpdb;
$author_id = 1;
$cat_id = 1;
$post_status="publish";
/* Post Titles */
$search_titles = $wpdb->get_col(
"SELECT DISTINCT post_title FROM $wpdb->posts
LEFT JOIN $wpdb->term_relationships ON
($wpdb->posts.ID = $wpdb->term_relationships.object_id)
LEFT JOIN $wpdb->term_taxonomy ON
($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
WHERE $wpdb->posts.post_status="$post_status"
AND $wpdb->posts.post_type="post"
AND $wpdb->posts.post_author = $author_id
AND $wpdb->term_taxonomy.taxonomy = 'category'
AND $wpdb->term_taxonomy.term_id = $cat_id"
)