Home › Forums › ACF PRO › Sort post by acf date first and after by title › Reply To: Sort post by acf date first and after by title
Here is the new code with meta_query but same results.
There is something I don’t understand…
add_action( 'pre_get_posts', 'films_query' );
function films_query( $query ) {
if ( !is_admin() && $query->is_main_query() && is_post_type_archive( 'films' ) ) {
$cat_hide = get_field('categorie_des_films_a_masquer', 'options');
$taxquery = array(
array(
'taxonomy' => 'categorie_films',
'field' => 'term_id',
'terms' => $cat_hide,
'operator' => 'NOT IN',
)
);
$query->set( 'posts_per_page', '-1' );
$query->set( 'post_status', 'publish' );
$query->set( 'tax_query', $taxquery );
$query->set( 'meta_query', array(
'relation' => 'AND',
'date' => array(
'key' => 'date_de_sortie',
'compare' => 'EXISTS',
)
)
);
$query->set( 'orderby', array(
'date' => 'ASC',
'title' => 'ASC',
)
);
}
}
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.