[Resolved] [Suggestion] use menu_order instead of date for ordering Elements

Home Forums Support [Resolved] [Suggestion] use menu_order instead of date for ordering Elements

Home Forums Support [Suggestion] use menu_order instead of date for ordering Elements

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #1188724
    Maarten

    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.

    #1189037
    Tom
    Lead Developer
    Lead Developer

    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.

    #1190074
    Maarten

    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?

    #1190278
    Tom
    Lead Developer
    Lead Developer

    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;
    } );
    #1191228
    Maarten

    Exactly what I was looking for!

    #1191374
    Tom
    Lead Developer
    Lead Developer

    Awesome ๐Ÿ™‚

    #1462694
    Maarten

    Hi Tom, the filter generate_elements_custom_args seems to have disappeared in version 1.11.2. Could you please bring it back?

    #1462900
    Tom
    Lead Developer
    Lead Developer

    Wow, not sure how that happened – very sorry!

    Re-added in 1.12.0.

    #1464195
    Tom
    Lead Developer
    Lead Developer

    All fixed in 1.12.0-rc.3?

    #1466036
    Maarten

    Yes it works again, thanks for the quick fix!

    #1466204
    Tom
    Lead Developer
    Lead Developer

    Awesome – thanks for letting us know ๐Ÿ™‚

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.