Php 为搜索查询wordpress添加额外参数
这是我的密码:Php 为搜索查询wordpress添加额外参数,php,wordpress,Php,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中无效,没
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();
?>