WordPress: Exclude Posts with Meta Value

To exclude WordPress posts with a specific meta value, you need to add the following code within your WordPress loop.

// Loop starts here
while (have_posts()) : the_post();
// Get the meta field
$meta = get_post_meta($post->ID, "Meta Name", false);
// Do no show post if the meta equals "Meta Value"
if($meta != "Meta Value"){
// Content Here
// Loop ends

So just replace “Meta Name” with the name of the meta field and “Meta Value” with the value you want to exclude.

Free Graphics, Icons, Tutorials
Free Graphics Free Christmas Vector Icon Graphics Pack 2017Free Fitness Vector Icons Graphics PackFree Camping Vector Graphics PackFree Summer Graphics PackFree File Icon PackFree Fast Food Vector Graphics
Sharing is caring...
Like & Follow
Share the love, share this page! Facebook Twitter Digg Reddit LinkedIn Pinterest Email
Close [X]
The Web Taylor
1000 Lakeside North Harbour Portsmouth, Hampshire PO6 3EN
02392 123358