vendredi 30 janvier 2015

Search tags in CPTs


I can't seem to figure out how to include tags in a wordpress search. For example, if I search for 'apple', I would like to get back posts with 'apple' in the title or the content (default wordpress functionality) as well as posts that contain the tag 'apple'; When I add the 'tag' => $keyword line into WP_query then I get no results for every search.



$keyword = get_search_query();
$args = array(
'post_type' => array('case_studies', 'news', 'events'),
'post_status' => 'publish',
's' => $keyword,
'tag' => $keyword,
);
$query = new WP_Query($args);


If I remove it, I get results as normal (but without posts with the keyword in its tags)





Aucun commentaire:

Enregistrer un commentaire