为搜索查询wordpress添加额外的参数


add extra arguments for search query wordpress

这是我的代码:

global $query_string;
$posts = query_posts($query_string . '&orderby=meta_value_num&order=DESC&posts_per_page=-1&meta_key=post_views_count');
while (have_posts()) : the_post();    
endwhile;

这段代码在分类归档页面中有效,但在search.php中不起作用,没有搜索结果。我的代码出了什么问题?我只想添加搜索结果的排序。

试试这个代码:

<?php
global $query_string;
query_posts($query_string . '&orderby=meta_value_num&order=DESC&posts_per_page=-1&meta_key=post_views_count');
while (have_posts()) : the_post();    
endwhile;
wp_reset_query();
?>