0

我有用于显示搜索结果的 wordpress 模板。它工作正常,但是当我想更改排序顺序时,我不能。query_posts 没有按预期工作 - 它没有显示任何结果。

这是我的代码的一部分:

global $query_string;
query_posts( $query_string . '&order=ASC' );
if (have_posts()) {
     theme_post_wrapper(
                array('content' => '<h4 class="box-title" >'. $count.'</h4>')
        );                                                          

            /* Display navigation to next/previous pages when applicable */
            if (theme_get_option('theme_top_posts_navigation')) {
                theme_page_navigation();
            }

            /* Start the Loop */
            while (have_posts()) {                    
                the_post();                        
                get_template_part('content', 'search');                                                 
            }

            /* Display navigation to next/previous pages when applicable */
            if (theme_get_option('theme_bottom_posts_navigation')) {
                theme_page_navigation();
            }

} else {
            //NO DATA FOUND
}

如果我删除 query_posts 则显示结果。如果我如上所述添加 query_posts,则不会显示任何数据。这很奇怪,我不知道该怎么做。如何调试?有没有办法获得类似 SQL 查询的东西?还有什么?请给我一些想法。

我还尝试将 order 或/和 orderby 参数添加为 GET 参数 - 搜索结果没有发生任何变化(没有更改排序)。

4

0 回答 0