Setting Custom Sort Order of Posts within a Category

Now that I have a better understanding of the issue, I would recommend using custom fields to sort your posts. You can have a custom field (e.g., “order”) and use it to indicate the order of your posts. You then need to use a custom query to order these posts when they are displayed. You can use a custom query like the following:

$args = array(
    'meta_key' => 'order',
    'orderby' => 'meta_value',
    'order' => 'ASC'
);

$custom_query = new WP_Query();
$custom_query->query($args);

if($custom_query->have_posts())
{
    while($custom_query->have_posts())
    {
        $custom_query->the_post();

        // Do the loop stuff
    }
}

Please see the WP_Query class page for more information about all of the arguments that you can use to create custom queries.

Leave a Comment