Exclude Featured Posts in WordPress ‘Recent Posts’ Function

So I tested it now and getting posts without a certain meta key in one query is not possible.

But: You can exclude them from another query like so:

    $featured_posts = get_posts( [
        'meta_key' => '_is_ns_featured_post',
        'meta_value' => 'yes',
        'fields'     => 'ids',
    ] );

    query_posts( array( 'post__not_in' => $featured_posts ) );

    while ( have_posts() ) : the_post();
        $output .= '<li>'.get_the_title().'</li>';
    endwhile;

    wp_reset_query();

Leave a Comment