Home › Forums › Backend Issues (wp-admin) › Page Link – Order by date NOT title? › Reply To: Page Link – Order by date NOT title?
That depends on if you’re allowing only one post type and if that post type is hierarchical or not.
If you you’re allowing multiple posts types or the post type is hierarchical, then no. The reason is that ACF groups the posts according to post type and parent page. Attempting to reorder them by date will cause the results to be broken.
If you are limiting it to a single post type and it is not hierarchical then the answer is a definite maybe. There are filters that you can use set the WP_Query args and you can change the order by.
Line 144 of /fields/page_link.php, I don’t think these filters are documented.
// filters
$args = apply_filters('acf/fields/page_link/query', $args, $field, $options['post_id']);
$args = apply_filters('acf/fields/page_link/query/name=' . $field['name'], $args, $field, $options['post_id'] );
$args = apply_filters('acf/fields/page_link/query/key=' . $field['key'], $args, $field, $options['post_id'] );
I have not tested this.
add_filter('acf/fields/page_link/query/name=FIELD_NAME',
'change_page_link_order_by', 10, 3);
function change_page_link_order_by($args, $field, $post_id) {
$args['orderby'] = 'date';
$arge['order'] = 'DESC';
return $args;
}
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.