tell me how to make that search results are sorted by date. it is first necessary to show the latest entries
that’s how it is done here by adding links: http://screenshot.net/jwkeck2
Here’s how your plug-in is displayed: http://screenshot.net/5yrnu7q
Hi @inforesist
Could you please tell me which custom field type was that? ACF has several hooks to modify the query of some custom field types. acf/fields/post_object/query for the post object field, acf/fields/relationship/query for the relationship field, and acf/fields/taxonomy/query for the taxonomy field.
I hope this helps.
Hi @inforesist
In that case, I believe you can do it like this:
function my_relationship_query( $args, $field, $post_id ) {
// only show children of the current post being edited
$args['orderby'] = 'date';
$args['order'] = 'DESC';
// return
return $args;
}
// filter for a specific field based on it's name
add_filter('acf/fields/relationship/query/name=relationship_custom_field_name', 'my_relationship_query', 10, 3);
Where “relationship_custom_field_name” is the name of your custom field. To learn more about the arguments, please take a look at this page: https://codex.wordpress.org/Class_Reference/WP_Query.
Hope this helps.
I have and it is written. but I can not achieve this sort result as a search in WordPress by adding links
may include a search by title?
Hi @inforesist
Could you please open a new ticket here: https://support.advancedcustomfields.com/new-ticket, and provide temporary admin credentials in that ticket so we can check the issue you have? Don’t forget to provide the link to this thread in the ticket.
Thanks!
The topic ‘Search results sorted by date’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.