Wordpress帖子以相反的顺序显示(最早的显示)

问题描述 投票:0回答:1

[我正在通过其Wordpress网站帮助朋友,他们的所有博客文章都以相反的顺序显示(最早的显示在前)。我没有找到负责任的插件,也没有确定添加的任何代码。我也尝试添加代码

//function to modify default WordPress query
function wpb_custom_query( $query ) {

// Make sure we only modify the main query on the homepage  
    if( $query->is_main_query() && ! is_admin() && $query->is_home() ) {

        // Set parameters to modify the query
        $query->set( 'orderby', 'date' );
        $query->set( 'order', 'DESC' );
        $query->set( 'suppress_filters', 'true' );
    }
}

// Hook our custom query function to the pre_get_posts 
add_action( 'pre_get_posts', 'wpb_custom_query' );```

They are using the theme RT-Theme 18

Does anyone have any idea why this might be happening?
php wordpress
1个回答
0
投票

如@fraggley所述,首先禁用所有插件并将主题设置为TwentyTwenty(默认主题)。 RT-Theme 18在其demo中也表现出类似的行为,没有明显的设置可以更改此行为。如果还没有,请确保您正在以儿童为主题进行自定义。在不创建新功能的情况下,尝试使用标准循环开始以查看顺序是否仍然不正确。

<?php

get_header();

if ( have_posts() ) : 

    while ( have_posts() ) : the_post();

        the_content();

    endwhile;

else :

    _e( 'Sorry, no posts matched your criteria.', 'textdomain' );

endif;

get_footer();

?>

通常将其放置在子主题根目录下的home.php或index.php中。 WordPress在codex中对此提供了很好的文档。您可以通过检查原始代码在父主题中出现在哪个文件中来确定。因此,如果循环发生在父主题home.php中,请在子主题的相同相对位置创建一个名为home.php的文件。有关此here的更多文档。

© www.soinside.com 2019 - 2024. All rights reserved.