After filtering the post list in the admin dashboard, how can I change the order of posts after filtering and it will display in the same order at the front end too?

1 Answer 1


Hello Radheeka Chopda and welcome to our lovely community.

I would highly suggest you first read How to ask good questions before making more questions.

But since I can assume what you are looking for, let me know if this code below helps you with your problem.


// Change the order of posts on the front end
function custom_frontend_posts_order($query) {
    if (!is_admin() && $query->is_main_query() && $query->get('post_type') == 'post') {
        $query->set('orderby', 'your_custom_order_field'); // Replace 'your_custom_order_field' with the same order field used in the admin dashboard
        $query->set('order', 'ASC'); // Set the same order as used in the admin dashboard
add_action('pre_get_posts', 'custom_frontend_posts_order');

Incase this is not what you're looking for, make sure to provide more information and the piece of code you are using to filter the post list in the admin dashboard, for us to help you figure things out!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.