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.
Hi @ivgogra
I’m afraid you need to modify the core file to do it. In “wp-content/plugins/advanced-custom-fields-pro/fields/post_object.php”, you can find this code:
$posts = acf_order_by_search( $posts, $args['s'] );
Simply comment it to disable the order by search.
I hope this helps 🙂