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:
PostMash Custom
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.
For everyone else: Unzip and upload to wp-content/plugins using your favorite FTP client, then activate in WordPress’ admin-area.
Then — in your theme’s index.php-file (or whereever you want to use it), find the beginning of “the loop”, starting with
if(have_posts())
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/



Tilbaketråkk: Anonym
Screenshot please…
Screenshot added, both on wordpress.org, and here :)
thankss. it works
http://babygenderonline.com
1. Using filter on the Reorder posts page, takes you to an invalid URL (a slash is replaced by %2F in the URL)
2. When clicking the Update button, there is a Timeout error message. Reordering is not saved.
*!”#*$%$&!!**! Sorry, I thought I had fixed those two, but I obviously f****ed up with how this wordpress repository-thing works, not quite used to that yet.
Both errors seem to be fixed here now with 1.0.3, which should show up in your updates any moment.
Thanks for the bugreport! :)
Torstein
Tilbaketråkk: PostMash Custom – Custom Post Order Plugin | Wordpress Plugins
I would love to use this plugin for my site (reecesrainbow.org — we advocate for orphans with special needs) — but it isn’t working with my theme. I get some js errors (just a yellow triangle at the bottom of my screen) that mention something about an object not being found and something wrong with mootools. Anyway, the lines stay gray and I can’t drag them. I had the same problem when I tried the other PostMash plugins, so it isn’t unique to yours. Would you be willing to debug a little if I paid you? What would you charge? I have a test server with everything set up that you could work on…
Thanks,
Lisa
Hello,
I do not know where to place the code you have listed inside the plugin?
Can you please tell me where it goes within the WordPress template?
Thank you,
Derek
I have tried putting the suggested code in page.php as the code you say should be in index.php is not there, but it is in page.php, but this still does not work
thanks
Hi Derek, which theme are you using? In some themes (like twenty ten) things are done a bit different than what has been the “standard” way for years.
However — page.php is definately not where you want to place it, that is the template for “pages”
can you help with this theme?
Hi Giovani,
which theme is that?
for twenty ten, see the solution i posted for Laurent, a little further down.
Great plugin! Any way to make the posts go into a random order? (I used the random sorting with native WordPress query, but I want to be a fixed, permanent order that’s always in the same order, just randomized the first time).
Sorry Graham, not with this plugin.
this is a great plugin!!
if i couldn’t find it i would have to write it myself for a CMS project I’m working on
thanks a lot
Nice to hear Bora :)
I’ve tried this plugin and added the code where you specify but it’s not working in WP 3.1 using the theme EvoLve.
Any suggestions?
Thanks in advaince
Vince
Hi Vince,
in EvoLve the same index-file handles the loop for several different templates for the theme. So the first if ( have_posts() ) is not the one we want. If you look through the code, on line 328 you find a comment that the loop for 2– or 3-columns layout (which I believe you use?) starts, and on line 382 you find what I believe is “your” if ( have_posts() ).
So, try adding the code on line 380–381, and I believe it should work :)
Hello,
Is it possible ton install this plugin in twenty ten theme. I dont find “if post” in index.php.
Thank you
Laurent
Hi Laurent,
in twenty ten the entire loop is moved to loop.php, so things seem a bit confusing at first. But it actually is still almost exactly the same we need to do, just replace the original code in twenty tens index.php-file, with this:
very much for this answer.
I’ll try it
Can anyone provide the modifications I would need to make to the functions file of a Thematic child theme in order to get the plugin to work right?
This page I stumbled across was useful for another (older) plugin allowing a similar manual reordering:
http://themeshaper.com/forums/topic/list-of-posts-in-a-category
Thanks in advance,
Tim
Hi Tim,
I’ll have a look on it in the weekend.
T.
Hi Torstein
I’m using arras-theme and have installed your plug in but i can’t get it to work as the line if(have_posts)) doesn’t exist as far as i can see.
I’ve tried installing the code you used for the Twenty Ten theme but that hasn’t worked either.
Can you help with where i should install the code?
Thanks a lot!
Adam
Hi Adam,
as long as you use wordpress, that line (or something very similar) is in there, somewhere, 100% certainly.
But — especially in more advanced themes, it may often be put somewhere else than index.php. I have not tried arras, but it seems home.php would be the correct file. However — there are several loops/queries on that page, so for each area you want to use this plugin, you must modify the query to use “order_by=menu_order” and “order=ASC”. This can be done in a few different ways, I cant take the time to have a more through look on arras right now, but it should be enough to drop these three lines in home.php in the query you want to modify.
$wp_query->set('orderby', 'menu_order'); $wp_query->set('order', 'ASC'); $wp_query->get_posts();Hi,
I’m using ShopperPress and I inserted the code in the line 90 of this page http://pastebin.com/LY2b2Pv6 which is the page where I want to order posts.
Also even though i don’t insert any code in the admin panel I can’t drag and drop post.…should I do anything to use the drag and drop?
Thanks
Hi Juri,
you should get a new button in the admin-menu, just beneath “posts”: http://dl.dropbox.com/u/27793/Skjermbilde%202011–04-02%20kl.%2018.48.31.png
I have the button and when I click on it I got posts displayed but I can’t drag and drop.
Also do you think in the line 90 is the right place to insert the code and make PostMash working? Now it’s not working at all in the back-end and front-end.…Thanks for your help
Hm, that probably means there is a conflict between the version of mootools used in postmash, and some of the javascripts shopperpress uses. And that is not easily fixed…
However, first of all: Try deactivating all other plugins, and see if it works then. If it does, try activating the other plugins one by one and check if it still works, if its another plugin that is the problem, you should find it quickly like this. Then you can see if you find a different plugin instead of the one causing the conflict.
Hello, in template ADVNewsPaper dont have the loop and If Have_post my code is
query('showposts='.$npdv_options["feaPostCount"].'&cat='.$npdv_options["featuredCatID"]);while ($gabquery->have_posts()) : $gabquery->the_post();
?>
how to replace this code?
Sorry for my english i’m French
Every few days, I have to go in and resort my posts by category. The top one always stays in the right place, but I can’t get the bottom one to stay at the bottom. Other posts — even posts I have made no changes to — are ending up at the bottom of the list.
Hi Torstein! Did you find which changes I need to make so I can use your plugin with Arras Theme?
Thank you.
Hi Bruno,
sorry, but as I said, I really don’t have time to look into that — there are something like a billion wordpress themes, and many of them use different files where they place the loop and the query, so I have absolutely no possibility to find out this for every theme.
However — it should be possible, and it is probably not very difficult either. My suggestion is that you ask the theme author.
all the best,
Torstein
Hi Svar,
I’m really confused, I placed your code in the index file, but how do I get to the Ajax interface?
Thanks
It works now, thank you!
alright! you’re welcome :)
Hello, thanks for this pluguin. I really needed it. But I have the following problem:
With the pluguin activated, I can order posts but I cannot update them, or upload photos, etc
If I try to update (save) a post, the error is:
Cannot modify header information — headers already sent by (output started at site-path.…/wp-includes/functions.php:3387) in site-path…/wp-includes/pluggable.php on line 897
If I try to upload an image, I get this error:
Cannot modify header information — headers already sent by (output started at site-path…/wp-includes/functions.php:3387) in site-path…/wp-admin/async-upload.php on line 26
I would appreciate any help. Thank you
hm, that sounds strange miquel, I’ll look into it. Meanwhile, could you try the old “deactivate other plugins”-trick, just to see of that solves it?
Tim Paterson,
// ACTIVATE POST MASH PLUGIN FOR THEMATIC
function postMash_orderPosts($orderBy) {
global $wpdb;
if(is_category(10)) {
echo “”;
}
elseif ( is_home() || is_front_page() ) {
echo “”;
}
else {
$orderBy = “{$wpdb->posts}.menu_order ASC”;
}
return($orderBy);
}
add_filter(‘posts_orderby’, ‘postMash_orderPosts’);
Uhh, that’s ugly try this
// ACTIVATE POST MASH PLUGIN FOR THEMATIC
// AND ONLY USE PLUGIN ON PORTFOLIO PAGES, HOME AND NEWS PAGE DEFAULTS TO WP
function postMash_orderPosts($orderBy) {
global $wpdb;
if(is_category(10) || is_home() || is_front_Page()) {
get_posts();
}
else {
$orderBy = "{$wpdb->posts}.menu_order ASC";
}
return($orderBy);
}
add_filter('posts_orderby', 'postMash_orderPosts');
Hey, thanks! I’ll add it to the guide!
Love the plugin, but I don’t have the option to reorder my custom post types. Do I have to put something in the post type definition or something so that PostMash is aware?
Lorin — check the answer below :)
I also don’t’ see how this works with custom post types. My custom post type posts are showing up under the posts>reorder posts area, which isn’t very useful. There’s also no menu to filter by post types, so I’m at a loss as to how it supports them at all.
@lorin & mpmchugh: I just tested with everything updated here, and I think I know what causes your problem:
It seems you must have a taxonomy for your post type, and the post must be in a category. Fix those two, and it should work :)
This is definately something that should be fixed (if no taxonomy or no category selected within taxonomy => use post type name for filtering option), but I really don’t have time for it right now. I also have a few other things on my list, but if someone is willing to fix it, I’m more than happy to give credit & a link in the plugin!
Would love to be able to use the plugin but I’m not able to re-order the posts (move them) using the Dynamix theme… Any suggestions? I’ve tried disabling plugins, no go.
Thanks.
You have remembered to insert the code provided? As long as you change the query for the loop so that it has orderby=menu_order, it should work on any theme
The plugin works great but I mainly need this to change the order of my posts based on the image that is in the post. Is there any way to show a small thumbnail of the first image in the post on the REORDER POSTS page?
Thanks.
Hm, at the time there is no option for that, but it would be nice, I’ll look into it
Thank you for your plugin, it’s a wonderful tool for my needs.
I’ve installed it on my theme (created with Artisteer and customized), I’ve used it, reordered my posts, and everything worked pretty well.
In the meantime I’ve installed other plugins. I think something has gone in confict with postMash. Now if I open the postMash options page in the Dashboard all the posts are grey, disabled, and I can no longer drag & drop them. Nevertheless, the posts order hasn’t changed, they’re still ordered as I wanted (when moving them was possible). And they remain correctly ordered even if I uninstall postMash, reinstall it, etc. So, apparently in the blog everything seems to work fine, except I can no longer drag any post!
I’m not a code expert, so I hope you can help me bring postMash back on track.
Thank you very much in advance!
Davide
Its probably another plugin that conflicts with PMC, try deactivating all other plugins, then check if PMC works again, and then try to reactivate the other plugins one by one, and you will find out which one it is that causes the problem :)
Hi, I didnt quite understand from what i read (and couldnt quite see how to do it if it is possible)… but is this plugin available to be used in a standard hosted WordPress site (.wordpress.com) ??
No, sorry, its probably not possible to use in a wordpress.com-hosted site, since you have to do a minor modification on the theme files to use it.
Hi,
I’m having an issue w/Post Mash in a WP 3.2 HTML5 CSS3 liquid layout site. Got it working after some struggles as a template called within home page:
2012 Featured Speakers
<a href=”” rel=“bookmark” title=””><article id=“post-” >
Live site is: http://www.greathomeschoolconventions.com/
(current display post number set at 24)
Screen grab of problem is: http://www.azzcatdesign.com/azzcatdevelopment/DEMOS/post_mash/query_48.jpg
(grab of display posts number set at 48)
Is this some sort of PHP problem in my implementation? I feel the CSS is OK, since 24 displays perfectly. My quest is for 36 posts…12 across/3 down.
Thanks!
Hi Catherine,
the css in the theme doesnt matter at all to this plugin, all the work is done by the database and the query.
Basicly — just get your site working without the plugin, then change the query for the posts you want to order, to orderby=menu_order, and order=ASC, and thats it :)
Post the query you are using here if you want, and I’ll have a look at it.
The plugin works just fine in the pages with the code, but I can’t seem to be able to drag my posts up and down to reorder them in the plugin admin. I am using wp 3.1
I use the following loop to get the titles of posts grouped by subcategory. Where would I put the code you recommend into this loop?
cat_name . ”;
echo ”;
$subcat_posts = get_posts(‘cat=’ . $subcat->cat_ID );
foreach($subcat_posts as $subcat_post) {
$postID = $subcat_post->ID;
echo ”;
echo ;
echo get_the_title($postID);
echo ;
}
echo ”;
} ?>
Thanks for any help.
Eileen
Whoa.…that code didn’t copy properly. Let me try again. Looks like it will be o.k., but not sure it will stick when I hit send…
cat_name . ”;
echo ”;
$subcat_posts = get_posts(‘cat=’ . $subcat->cat_ID );
foreach($subcat_posts as $subcat_post) {
$postID = $subcat_post->ID;
echo ”;
echo ;
echo get_the_title($postID);
echo ;
}
echo ”;
} ?>
Nope. Didn’t stick. Is there a special way to copy php code into a comment so it doesn’t get messed up when you hit send?
Can you let me know if this plug in can reverse order of the posts (so posts appears in 1, 2,3 … order) wtihout changing the post order in “Most Recent Posts ” (oder in 17, 16, 15 .….. 3, 2, 1)? My current theme is Green Theme.
Also, I tried using plug in, but the post order lost random? Do you know why? (e, g. 3, 4 1, 2, 5 etc…)
Thank you so much.
hi
this is my code for next/back/previous
<?php next_post_link(__(‘%link’, ‘framework’), ‘%title’) ?>
<a href=””>
<?php previous_post_link(__(‘%link’, ‘framework’), ‘%title’) ?>
if i use your plug to order the post — what do i need to do that the these links will go acoording the new order ?
<?php next_post_link(__(‘%link’, ‘framework’), ‘%title’) ?>
<a href=””>
<?php previous_post_link(__(‘%link’, ‘framework’), ‘%title’) ?>
I am using the PostMash Custom plugin on my portfolio site, and it is very useful for reordering content in my “Project” custom post type, but the suggested next_post_link_menu() and previous_post_link_menu() links do not work when used in my single “project” display template. They do not appear at all.
I do not use “categories” for my “project” post type, only a variety of custom taxonomies. If I alter the plugin code to set “in_same_cat” to false, the links do appear, but they then link to blog posts rather than projects.
Is there a way to get the PostMash Custom next and previous post links to work with a custom post type in the custom post single display template?
Thanks for a great plugin!
Please help i have fullscreen template in wp i tried adding the code with and without it i see the reorder posts and i do and hit update but nothing changes on my page any ideas?
I am trying to follow your directions but I can’t find anything in the index.php I find it in the pages.php. I am a novice with dealing with coding on WP . I not sure where to place it and I would really want to see how this works if it is going to fix my problem with my posts being out of order. Please respond as soon as you can.
Thank you
What I need is a plugin that allows drag-and-drop manual ordering of posts in the WordPress “Posts” admin page. Anybody know of any such thing? I thought PostMash Custom’s changes would be reflected in the admin listing of posts, but no.
Hi Jesse,
no, in the “Posts” admin page the posts are listed by date (not sure if its by creation date or publishing date). Its probably possible to change that, but I’ve never seen anything that lets you reorder them by drag/drop right there — thats why this plugin exists — I had the same need myself.
Tilbaketråkk: ドラッグアンドドロップで簡単に並び順を変更できるWordPressプラグインまとめ | モンキーレ
When using this under 3.3.1 it says ‘updated successfully’ but then all pages on the site throw a 404 and wp-admin is inaccessible.
Deleted and restored database to get out of this, and repeated to confirm.
Hmm, that sounds strange, I have several sites where its used, which does not give that error. What theme do you use, Frances?
Hi Torstein,
thanks for your quick reply. It’s a custom theme I have made, with multiple loops pulling in different custom post types as well as posts.
I’ve tested it separately in a local install (wp 3.1.1, twentyeleven 1.3) and it works ok there.
The strange thing is that it affected wp-admin also, so I would get “There was a problem processing your request.” until I dumped the db and restored from backup.
I also tried the other plugins based off the original PostMash, and these resulted in the same problem.
Sorry that’s not much to go on, I’ll look into it more.
Frances
No problem, its interesting to know about anything like that since I use this plugin on several sites for clients myself. Ok, two quick ideas:
You have tried doing the update again?
What happens if you turn off the plugin before updating, and turn it back on after updating?
None of that works. I tried the usual: uninstalling the plugin via ftp, uninstalling all plugins, deleting everything in functions.php, and even deleting all but the wp stuff in htaccess, and none of that worked. As soon as I updated with the plugin, the whole site fell over.
It is working on other sites though, so it’s likely some unique combination of everything.
Those who are using Thesis theme need to add this code to custom php to make postMash work:
function postmash_custom_post_order(){
if (is_front_page()){
global $query_string;
query_posts( $query_string . ‘&orderby=menu_order’ );
}
}
add_action(‘thesis_hook_before_content’, ‘postmash_custom_post_order’)
heya
would you consider updating your plugin to use jquery mobile so we’ll be able to use drag controls on mobile devices like the ipad also?
thanks in advance!
Hi Alex,
I’d definately consider that, however — the plugin is currently using mootools, not jquery. And here we have a couple of problems:
1: I have too much work & not enough time,
2: my one-year-old daughter and my GF…
3: JS/jquery/mootools is *really* not what I do best …
SO — if anyone with more time and the neccessary skills would like to help out with this, I’d gladly give you access and credit. I could even pay someone to do it, if anyone is interested?
Hi. We are using the following method to get posts:
<article id=“post-” class=“post”>
<time class=“date” datetime=””>
<a href=”” title=””>
<?php the_content(‘Read the rest of this entry »’); ?>
How do we integrate the plugin?
Hi, I am using The Architect Them and below is the original code from index.php, can you please show me where the code goes . I tried but didnt work
<img src=”” alt=”” />
—
<a href=”” title=””>
i use WP Custom Post Lists and I wondered if I could somehow get it to recognized the sort order created by your plugin? it has a pulldown in the widget that offers ASC or DESC. i don’t know much about editing plugins but it seems so useful to be able to do this!
Does this work with featured categories and featured sliders? I really need to know whether it does or not — If you don’t have time to tell me how that is fine — I will keep trying to figure it out if I know that it does. Here is my code.
Business Updates
query(‘category_name=business-updates&showposts=4′,‘orderby=menu_order’);
while($businessFeaturePosts->have_posts()) :
$businessFeaturePosts->the_post();?>
<a href=”” title=””>
No reason it shouldn’t work there, Marisa, but I believe you have a couple of errors in your query:
query(‘category_name=business-updates&showposts=4′,‘orderby=menu_order’);
should be
query(‘category_name=business-updates&showposts=4&orderby=menu_order’);
Hi I’d love to use your plug in, its just what I need but can’t seem to get it to work.
I’m using the “hatch” theme
any help much appreciated
thanks
tried this and both older postmash plugins and none of them seem to work.
added the query code before the if(have_posts()) in the index of the theme, but it doesn’t work.
where am i supposed to find the to add ‘orderby=menu_order&order=ASC’? i went trough all of the theme’s files, even the ones im sure don’t have to and i couldn’t find even one get_posts.. using zeesynergie as theme.
any help is appreciated, cheers!
Tilbaketråkk: How to Change the Post Order in WordPress | 5E, making unique websites
I change the order, but it’s not updating on my site.
Is it possible to filter by Tag? Filter by category/date brings to many post in the admin panel.
Would be real help.
Suddenly I get a Timeout Error when I try to update the order of the posts.
Could be because I updated to 3.5? Prior to that I been using the plugin for long time without any issues.
The order itself is still working, all the post keep the order they had but I cant change it anymore.
Please help, otherwise I would have to switch to other plugin… the plugin has not been updated since march 2011 and this site seems to be abandoned also half a year ago, so…
Timeout Error..I guess its because the latest update of wordpress…
Please I wish you fix it
thank you
Hi, I’m a writer based out of Wattle Grove, Australia and I discovered your site via http://opperud.com/postmash_custom/. Do you have any helpful hints for up-and-coming writers? I’m hope to start my own page very soon but I’m a bit lost on everything. Could you recommend starting with a free platform like Nucleus or go for a paid choice? There are so many options out there that I’m quite overwhelmed.
.. What would you say?
All large purchases are always intimidating, especially if you are uninformed
about the industry. One of the scariest purchases is buying
cars. Many people fear they are getting ripped off
and you surely don’t want that. Avoid buying a lemon by looking through these great tips and tricks regarding car purchases.