Drag’n’drop reordering of posts, now also for custom post types and taxonomies!
You might know the plugin PostMash, and its spinoff PostMash (filtered). Both very nice plugins, allowing drag’n’drop reordering of posts. Especially for those of us using WordPress as a CMS this is a very nice feature to offer our webdesign clients. But time went by, and neither plugin were ever updated for Custom Post types / Custom taxonomies, as introduced in WP 3.0. Enter PostMash Custom!
The new custom post types and custom taxonomy features introduced in WP 3.0 boosted WP’s capabilities as a CMS to a whole new level, and I quickly started using these new features for my webdesign clients, making event calendars, portfolio sites and lots of other features a lot easier to use, and more dependable and easier to customize than beeing dependent on plugins for every little feature. But drag’n’drop sorting of posts were sorely missed.
So, finally I had to do get something done myself. Here is the result — free for all:
How to use:
Usage is exactly the same as its predececessors postMash/filtered, so if you know/use those, you can just switch with this without any further work.
Then — in your theme’s index.php-file (or whereever you want to use it), find the beginning of “the loop”, starting with
Directly before that, add the following code:
<?php $wp_query->set('orderby', 'menu_order'); $wp_query->set('order', 'ASC'); $wp_query->get_posts(); ?>
This just tells WP to get the posts ordered according to their “menu_order” position. Therefore you can get the posts ordered anytime you use a function such as get_posts simply by giving it the required arguments:
<?php get_posts('orderby=menu_order&order=ASC'); ?>
Instructions for Twenty Ten
Things may seem a bit different in Twenty Ten, since the loop has been moved from the individual templatefiles into loop.php, but actually it still works almost exactly the same. Below is the entire code you need for Twenty Tens index.php:
<?php /** * The main template file. * * This is the most generic template file in a WordPress theme * and one of the two required files for a theme (the other being style.css). * It is used to display a page when nothing more specific matches a query. * E.g., it puts together the home page when no home.php file exists. * Learn more: http://codex.wordpress.org/Template_Hierarchy * * @package WordPress * @subpackage Twenty_Ten * @since Twenty Ten 1.0 */ get_header(); ?> <div id="container"> <div id="content" role="main"> <?php $wp_query->set('orderby', 'menu_order'); $wp_query->set('order', 'ASC'); $wp_query->get_posts(); ?> <?php /* Run the loop to output the posts. * If you want to overload this in a child theme then include a file * called loop-index.php and that will be used instead. */ get_template_part( 'loop', 'index' ); ?> </div><!-- #content --> </div><!-- #container --> <?php get_sidebar(); ?> <?php get_footer(); ?>
More info in the readme in the zip.
The plugin will also be added to WP’s repository asap. The plugin can now be downloaded at http://wordpress.org/extend/plugins/postmash-custom/