• Hi,

    I have a post object field and I use the acf/fields/post_object/query hook to query the posts ordered by date. This is my function:

    function my_post_object_query($args) {
        $args['orderby'] = 'date';
        $args['order'] = 'DESC';
    
        return $args;
    }
    add_filter('acf/fields/post_object/query', 'my_post_object_query');

    It works great. When I focus in the post object field it returns the posts ordered by date. But if I type something in the post object field they are not ordered by date. I would like it returns posts wich contain the string typed but ordered by date. Is this possible? How can I do it?

    Thanks.

    https://ww.wp.xz.cn/plugins/advanced-custom-fields/

The topic ‘Order post objects by date when typing’ is closed to new replies.