2017 © Pedro Peláez
 

wordpress-plugin wp-organise-posts

Set the display order of WordPress 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.

image

carawebs/wp-organise-posts

Set the display order of WordPress 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.

  • Monday, June 5, 2017
  • by DavidEgan
  • Repository
  • 1 Watchers
  • 0 Stars
  • 15 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 11 Versions
  • 0 % Grown

The README.md

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., (*1)

Build Notes

A post meta value is used to order projects on project-category taxonomy archive pages., (*2)

It was tricky to create a modified loop that displayed:, (*3)

  • 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., (*4)

<?php
/**
* Set a custom order for posts
*
* This is a callback for the `pre_get_posts` filter hook
*
* @see https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts
* @param  object $query The $query object - passed by reference.
* @return void
*/
public function custom_order ( $query ) {

    // Get the term that is being displayed for the given custom taxonomy
    $this_term = $query->query['project-category'];

    // Standardised key for post meta
    $key = "project-category-$this_term";

    $query->set( 'meta_query', [
        '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:, (*5)

<?php
public function custom_order ( $query ) {

    // Get the term that is being displayed for the given custom taxonomy
    $this_term = $query->query['project-category'];

    // Standardised key for post meta
    $key = "project-category-$this_term";

    // Set the meta_key and orderby it's value
    $query->set('meta_key', $key);
    $query->set('orderby', ['meta_value' => 'ASC', 'date' => 'DESC']);

}
<?php
// query in old format
$query->set( 'meta_query', array(
    'relation' => 'OR',
    array( 'key' => $key, 'compare' => 'EXISTS' ),
    array( 'key' => $key, 'compare' => 'NOT EXISTS' )
    ) );
    $query->set( 'orderby', [ $key => 'ASC', 'date' => 'DESC' ] );

The Versions

05/06 2017

dev-master

9999999-dev http://example.com/

Set the display order of WordPress 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.

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

plugin wordpress

05/06 2017

0.1.5

0.1.5.0 http://example.com/

Set the display order of WordPress 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.

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

plugin wordpress

03/04 2017

0.1.3

0.1.3.0 http://example.com/

Set the display order of WordPress 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.

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

plugin wordpress

03/04 2017

0.1.4

0.1.4.0 http://example.com/

Set the display order of WordPress 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.

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

plugin wordpress

03/04 2017

dev-orderfix

dev-orderfix http://example.com/

Set the display order of WordPress 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.

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

plugin wordpress

23/02 2017

0.1.2

0.1.2.0 http://example.com/

Set the display order of WordPress 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.

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

plugin wordpress

23/02 2017

0.1.1

0.1.1.0 http://example.com/

Set the display order of WordPress 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.

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

plugin wordpress

23/02 2017

0.1.0

0.1.0.0 http://example.com/

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.

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

plugin wordpress

23/02 2017

0.0.2

0.0.2.0 http://example.com/

This is a short description of what the plugin does.

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

plugin wordpress

23/02 2017

dev-wp-cli-commands

dev-wp-cli-commands http://example.com/

This is a short description of what the plugin does.

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

plugin wordpress

18/01 2017

0.0.1

0.0.1.0 http://example.com/

This is a short description of what the plugin does.

  Sources   Download

GPL-2.0+

The Requires

 

The Development Requires

plugin wordpress