Support

Account

Home Forums ACF PRO Order post objects by alphabetical order on edit screen

Solving

Order post objects by alphabetical order on edit screen

  • Hi,

    Is there a way to reorder the selected post objects by alphabetical order while editing the post?

    I tried the following code with no effect:

    
    function my_post_object_query( $args, $field, $post )
    {
        // modify the order
        $args['title'] = 'date';
    
        return $args;
    }
    
    // filter for a specific field based on it's name
    add_filter('acf/fields/post_object/query/name=cursos_tecnicos_presenciais', 'my_post_object_query', 10, 3);
    

    I don’t know if its relevant but the post object i’m trying to sort is being shared between 2 different custom post types via the plugin acf-post2post

  • I don’t understand what you code is attempting to do.

    
    $args['orderby'] = 'title';
    
  • Oh, my bad that made no sense at all. But even when it was like you showed it didn’t work.

  • I’m going to need more information. I don’t understand what you’re trying to do.

  • Ok, I have a post object field on my custom post type, its a list of courses.
    As i add them they don’t have any particular order, it’s by adding order so:

    Courses
    G
    B
    A
    C
    F

    What i’m trying to achieve is to force them to follow and alphabetical order by title, even if i add course A after i added course F for example A should always be the first.

    Courses
    A
    B
    C
    F
    G

  • Sorry for taking so long to get back to this.

    Exactly where are you trying to force them to be listed in this order?

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.