Support

Account

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);