Home › Forums › Backend Issues (wp-admin) › Sort CPT entries by an ACF field › Reply To: Sort CPT entries by an ACF field
your need to see if orderby is in the url query. This cannot be done by looking at $query->get( 'orderby');
because by the time of pre_get_posts WP has already set it to the default of date in the admin.
if (empty($_GET['orderby'])) {
// set default orderby
}
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.