How to create a WP_Query to search the Title or Tag?
Question
I have created a search using WP_Query, it seems like this query is looking for the queried term in title AND tags.
Is there a way to have this search the title OR tags?
$s = $request['s'];
$tags = str_replace(' ', '-', strtolower($request['s']));
$paged = $request['page'];
$posts_per_page = $request['per_page'];
$result = new WP_Query([
'post_type' => 'post',
'category__in' => 3060,
'posts_per_page' => $posts_per_page,
'paged' => $page,
'orderby' => 'date',
'order' => 'desc',
's' => $s,
'tag' => array($tags)
]);
0
php, query, search, tax-query, wp-query
5 years
2019-01-15T07:54:34-05:00
2019-01-15T07:54:34-05:00 0 Answers
64 views
0
Leave an answer