iBegins
 

Code sắp xếp danh mục theo thứ tự abc-xyz cho wordpress

Trước tiên bạn mở code functions của bạn lên và gắn code sau vào để thực hiện yêu cầu.

Code dưới đây để sắp xếp các danh mục theo archive php của wordpress

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', 'ASC' );
           //Set the orderby
           $query->set( 'orderby', 'title' );
        endif;    
    };

Chúc các bạn thành công.

Ngày 19 Tháng Bảy, 2019 ( 814 )

Tagged with: , ,

Bình luận bài viết

Đăng nhập để bình luận và xem các bình luận khác.