Archived topic
[Suggestion] use menu_order instead of date for ordering Elements
10 replies · Started by Maarten on March 8, 2020
Currently it is a bit complicated to sort Page Hero display rules
https://docs.generatepress.com/article/conflicting-display-rules/
Would it be an idea to use the menu_order (by adding 'page-attributes' to the post type) to sort the elements?
In that way you easily reorder the elements and don't have to create all the exclude rules.
It would even be possible to use a plugin like this https://wordpress.org/plugins/simple-page-ordering/ to sort with a drag and drop interface.
Hi there,
Making this sort of change would likely be a nightmare when it comes to backward compatibility.
What I can do is make the ordering filterable in the next version, so you can alter the args to better suit your workflow.
Hi Tom, I agree that BC would become complicated. Filtering the ordering sounds like a good idea. Would that mean I can add a custom field or enable page-attributes myself and then order the query by that?
In 1.10, you should be able to do this:
add_action( 'init', function() {
add_post_type_support( 'your_post_type', 'page-attributes' );
} );
add_filter( 'generate_elements_custom_args', function( $args ) {
$args['orderby'] = 'menu_order';
return $args;
} );
Exactly what I was looking for!
Awesome :)
Hi Tom, the filter generate_elements_custom_args seems to have disappeared in version 1.11.2. Could you please bring it back?
Wow, not sure how that happened - very sorry!
Re-added in 1.12.0.
All fixed in 1.12.0-rc.3?
Yes it works again, thanks for the quick fix!
Awesome - thanks for letting us know :)