Skip to content

Instantly share code, notes, and snippets.

@larodiel
Created April 6, 2021 04:24
Show Gist options
  • Save larodiel/ec07d31b504fd09693d99d25fd8c281a to your computer and use it in GitHub Desktop.
Save larodiel/ec07d31b504fd09693d99d25fd8c281a to your computer and use it in GitHub Desktop.
ACF meta query to exclude posts
<?php
// WP_Query arguments
$args = array(
'post_type' => 'post',
'post_status' => array( 'publish' ),
'posts_per_page' => -1,
'ignore_sticky_posts' => true,
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'exclude_post_from_home',
'value' => '1',
'compare' => 'NOT EXISTS'
),
array(
'key' => 'exclude_post_from_home',
'value' => '1',
'compare' => '!='
)
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment