Home › Forums › General Issues › Pre get Posts Show posts first if has acf value › Reply To: Pre get Posts Show posts first if has acf value
Thanks for the advice, I’ve tried the following based on the example to no avail.
Featured is set at True / False field as mentioned in example 2.
function custom_post_type_archive_jobs($query) {
if ($query->is_post_type_archive(‘jobs’)) {
$query->set(‘orderby’, ‘meta_value’);
$query->set(‘meta_key’, ‘featured’);
$query->set(‘posts_per_page’, ‘-1’);
$query->set(‘order’, ‘ASC’);
}
}
add_action(‘pre_get_posts’, ‘custom_post_type_archive_jobs’, 9999);
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.