wordpress 带有“post_title LIKE 'something%'”和类别的 WP_Query
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25761593/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WP_Query with “post_title LIKE 'something%'” and category
提问by jignesh886660
I need to do a WP_Query with a LIKE on the post_title and category
我需要在 post_title 和 category 上用 LIKE 做一个 WP_Query
This query_post is not working
此 query_post 不起作用
query_posts(
array(
'post_type' => 'add_buying',
'like' => $keywords,
'posts_per_page' => 5,
'taxonomy' => 'add_country',
'term' => 'drawing'
));
回答by Dharmik
回答by MISSIRIA
Change your second parameter to 's' and I think it's going to work:
将您的第二个参数更改为 's',我认为它会起作用:
$args = array(
'post_type' => 'post',
's' => $search_term,
'post_status' => 'publish'
);
$wp_query = new WP_Query($args);
And good luck
还有祝你好运
回答by MISSIRIA
title (string) - use post title (available with Version 4.4).
title (string) - 使用帖子标题(在 4.4 版中可用)。
$args = array(
'post_type' => 'post',
'title' => $title,
'post_status' => 'publish'
);
$wp_query = new WP_Query($args);

