Carawebs Organise Posts
WordPress plugin that allows posts and custom post types to be ordered by drag-and-drop.
by David Egan · github.com/carawebs/wp-organise-posts · website
★ 1stars
24composer installs
0forks
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/carawebs/wp-organise-posts/archive/refs/heads/master.zipAlso on Packagist as carawebs/wp-organise-posts:
composer require carawebs/wp-organise-postsFrom the readme
Organise Posts by Drag and Drop
Set the display order of Custom Post Types by drag and drop on the posts edit screen. Ordering is achieved by an index that is set when you drag and drop them in place.
Build Notes
A post meta value is used to order projects on project-category taxonomy archive pages.
It was tricky to create a modified loop that displayed:
FIRST: projects with the relevant post meta key set, in the correct order as determined by the value
SECOND: projects without the key
The key value pairing will be added after sorting, so it is important that all projects are shown, even if they don't have the key.
~~~
query['project-category'];
// Standardised key for post meta
$key = "project-category-$thisterm";
$query-set( 'metaquery', [
'relation' = 'OR',
[ 'key' = $key, 'compare' = 'EXISTS' ],
[ 'key' = $key, 'compare' = 'NOT EXISTS' ]
]);
$query-set( 'orderby', [ $key = 'ASC', 'date' = 'DESC' ] );
}
~~~
This simple query returns all posts with the key, by value order:
~~~
query['project-category'];
// Standardised key for post meta
$key = "project-category-$thisterm";
// Set the metakey and orderby it's