2014-09-10 100 views

回答

5

檢查this url和更改like參數。

query_posts(array(
'post_type' => 'add_buying', 
's' => $keywords, 
'posts_per_page' => 5, 
'taxonomy' => 'add_country', 
'term' => 'drawing' 
)); 
+1

正如一個便箋,這也搜索一個帖子的內容。 – Perspective 2016-05-09 20:22:11

+0

我意識到這個答案的上下文是基於原始問題,但作爲其他人的一般說明:_never,ever use_' query_posts'(僅供參考:http://stackoverflow.com/a/25589475/988246) 。它應該只能被核心使用。使用'WP_Query'或'get_posts'等許多其他許多功能,其中可以安全使用相同的參數數組。 – indextwo 2016-06-01 14:32:34

3

更改你的第二個參數的',我認爲這是去上班:

$args = array(  
    'post_type' => 'post', 
    's'   => $search_term, 
    'post_status' => 'publish'  
); 
$wp_query = new WP_Query($args); 

祝你好運