1

I wish to display my posts, not according to the date, but to a completely custom criterion. Ideally, I would manually set a numerical value to each post and the WP loop would display posts according to this value.

So if post X has value 1, post Y has value 2 and Z value 3, it would display first X, then Y, than Z, even though the date criterion would entail a different order. Hope it makes sense.

How to achieve this?

1 Answer 1

1

Save the order in a Custom Field, then modify the main query to order on that custom field via pre_get_posts. Example for posts page:

function wpa_custom_order( $query ) {
    if ( $query->is_home() && $query->is_main_query() ) {
        $query->set( 'meta_key', 'your_order_key' );
        $query->set( 'orderby', 'meta_value' );
    }
}
add_action( 'pre_get_posts', 'wpa_custom_order' );
3

Your Answer

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

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