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

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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.