Rearranging Post Types in WordPress: A Guide

If you’re a WordPress user who has been developing themes and using custom post types, you may have encountered the problem of rearranging the order of your published posts. Unfortunately, WordPress doesn’t offer an easy and manageable way to do this. In this article, we will discuss four methods that you can use to reorder your custom posts.

Method 1: Change Post Date

The first method involves changing the published dates of your posts. Most themes use the default order_by => date argument, which means that custom posts will show up in the order in which they were published. To change the post date, simply click “quick edit” on any post in the dashboard and alter the date using the fields, then click “update.”

Method 2: Altering the “Menu Order” Position

If the custom post type supports the “menu_order” function, you may also be able to change the order by altering this value. For example, in our Total WordPress Theme, we’ve enabled this for all built-in post types, making it easier to control your post type order for the front-end.

Method 3: Using The Post Type Order Plugin

Our favorite way of changing the order of your posts is by using the “Post Type Order Plugin.” This plugin allows you to easily move your posts around in a drag-and-drop fashion. You can find this plugin on the WordPress Plugin Page.

Method 4: Using the pre_get_posts Filter

If you want to reorder your items via code, it’s also very easy. You’ll want to use the pre_get_posts action in WordPress to do so. Here’s an example:

function wpex_order_category( $query ) {

// exit out if it’s the admin or it isn’t the main query

if ( is_admin() || ! $query->is_main_query() ) {

return;

}

// order category archives by title in ascending order

if ( is_category() ) {

$query->set( ‘order’ , ‘asc’ );

$query->set( ‘orderby’, ‘title’);

return;

}

}

add_action( ‘pre_get_posts’, ‘wpex_order_category’, 1 );

In conclusion, there are several ways to reorder your custom posts in WordPress. Whether you prefer to change the post date, alter the “menu_order” position, use a plugin, or use the pre_get_posts filter, there is a method that will work for you. Try out each method and see which one works best for your needs.

Stay in Touch

spot_img

Related Articles