Php Wordpress分类帖子的奇怪顺序

Php Wordpress分类帖子的奇怪顺序,php,wordpress,article,Php,Wordpress,Article,有人见过这个吗 当我们在这里访问wordpress类别帖子时: 在最上面一条,它不是最新发布的文章,而是最老的一篇 php代码的哪一部分应该更改?这是为wordpress版本的4.5从 如果您使用任何自定义查询,也可以在post循环“order”=>“DESC”中添加此查询 $args = array( 'post_type' => 'post', 'order' => 'DESC', ); $q = new WP_Query($args);

有人见过这个吗

当我们在这里访问wordpress类别帖子时:

在最上面一条,它不是最新发布的文章,而是最老的一篇

php代码的哪一部分应该更改?这是为wordpress版本的4.5从

如果您使用任何自定义查询,也可以在post循环“order”=>“DESC”中添加此查询

     $args = array(
    'post_type' => 'post',
    'order' => 'DESC',  );

    $q = new WP_Query($args);
或者将其粘贴到function.php中
您使用的是自定义查询还是defaul archieve或category页面,请共享您的模板代码,以便我可以帮助您。将此粘贴到function.php中。。。。。。。。。。。。。。函数change_category_order($query){$category=get_queryed_object();$cat_id=$category->term_id;if($query->is_category($cat_id)&&&$query->is_main_query()){$query->set('order','DESC');}}添加动作('pre get_posts',change_category_order');应该更改哪个文件?我只是使用模板,以前没有更改任何文件,只有模板除外@technodesigner在theme function.php中只需粘贴上面的代码。从“功能到最后”。
     $args = array(
    'post_type' => 'post',
    'order' => 'DESC',  );

    $q = new WP_Query($args);
   add_action( 'pre_get_posts', 'my_change_sort_order'); 
     function my_change_sort_order($query){
     if(is_archive()):
     //If you wanted it for the archive of a custom post type use:          is_post_type_archive( $post_type )
       //Set the order ASC or DESC
       $query->set( 'order', 'DESC' );
       //Set the orderby
       //$query->set( 'orderby', 'title' );
    endif;    
};