If you don’t use any other meta data, just add the following to your $args
:
'meta_key' => 'sold',
'meta_value' => true, // or whatever it is you're using here
'meta_compare' => '!=',
Otherwise, use a WP_Meta_Query
:
'meta_query' => array(
array(
'key' => 'sold',
'value' => true, // or whatever it is you're using here
'compare' => 'NOT LIKE',
),
),
See here for more information:
Related Posts:
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- Exclude a specific post in a Custom Post Type
- Display all posts in a custom post type, grouped by a custom taxonomy
- How to use a custom post type as front page?
- WP_Query() show posts that end later than today
- Display several random posts, but make sure a condition is met
- Retrieving 3 latest post from each of 5 different custom post types
- WP_Query on custom post type not displaying, multiple loops & get_template_part
- How to create posts (not post template) to be displayed on projects page?
- WP_Query post at custom position
- Comparing timestamps in meta query doesn’t work
- Display two post types ordered by two custom fields
- Combine tax_query and meta_query in WP_Query
- Should unaltered default loop/query return a list of custom posts belonging to a custom taxonomy?
- Query Custom Post by Category
- How do I Use Nested Loops of Custom Post Types for MultiSite Blogs using WP_Query()
- WP_Query and using a variable for ‘cat’=> in the args array = WP Bug?
- Filter posts with meta_query NOT IN where value has multiple values
- Exclude the parent custom post-type posts only
- Separate Posts and Custom Post Type in Custom Taxonomy archive template
- Impossible to get Attachments Outside WordPress?
- Help Structuring Query for Archive Pages
- Loop on front-page.php
- Filtering by Post Meta Custom Fields – Performance
- wp_query to find posts by year and month
- WP_Query | ‘post_type’ doesn’t work
- Filter by custom taxonomy slug on a custom post type
- Query custom post type in the loop
- Loop through Custom Post Type, and then show children within each iteration
- Very Slow Page – How to Optimize # of Queries?
- Can I create a loop with multiple post types and specify different $args for each post type?
- WP_Query orderby modified to include custom meta changes
- How to make sure content doesn’t display if selection is empty
- wp_query check if integer exists in custom field’s array
- Custom loop with multiple taxonomy queries
- A method for ordering mixed dates in search result loop (theory only, no actual code)
- How to do WP_Query with two meta fields with orderby clause
- Stuck in Order by more then one
- What’s the WP way to load remaining custom posts?
- WP Query with categories only shows one post and ignores the category
- pagination not working for category.php (custom post types in categories)
- Query based on custom fields start and end date
- WP Query post__in not returning correct results
- Sort posts in loop by the WooCommerce Membership of the author
- How can I group posts by months and years?
- Custon Content within WordPress Loop
- get_pagination not working on a custom post type query (using WP_Query)
- WP_Query with custom post type ID
- Getting a custom post’s custom field based on another custom post’s custom field select
- Having Issue on Ordering CPT by Custom Field In Custom WP Query
- WP_Query of custom post type sorted by meta_key has unexpected results
- display posts of custom post type with custom taxonomy
- postsperpage value not being applied
- Create a WP_Query where if the first value of the first row is equal to the second compare other value
- Exclude latest post from WP_Query taxonomy term loop
- Display the current post in browser as the first post in a loop (for a slideshow)
- Display post from custom post type
- Query Posts, order by meta value
- WordPress giving a 404 page when passing a year argument different than the current year
- foreach loop inside the loop creating duplicates in output
- Sorting by meta_key different to search criteria?
- How to retrive Custom Post Type Meta Fields in Custom WP_Query
- How to fetch posts that are stored in the different table than (default) wp_posts?
- Cant’ Display Custom Post Type Title Base on Tax Terms
- Loop for custom-post-type comparing taxonomy terms for “related” posts?
- What is the most efficient way to execute recursive complex queries?
- Pagination Not Working When Used With WP_Query() `offset` Property
- meta query condition don’t work
- Use WP_query to match post types based on custom field values
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- Wrapping an unknown amount of posts inside separate HTML Containers during WP_Query loop
- subtracting the current post form then whole loop, which is generating all CPT titles
- Mix Facebook and Twitter feed into custom posts
- sorting in wp query based on custom field value
- Custom post Query and WordPress Post Query Clash
- Meta_Query refuses to return results
- WordPress loop add heading before first of type
- Only show current category post
- How to make a shortcode for my WP_Query Loop? [duplicate]
- Strange behavior on WP_query
- get_post_meta for Custom Post Type ( CPT )
- Query events post type after current date and timezone
- Conditional posts in WP_query for search
- How To Loop Through list with Custom Post Types
- Is it possible to add query parameters on the archive page?
- Custom Post Type + Category archive
- Loop with Custom Post Type and Taxonomies
- display news with pictures 3 small and one large (loop)
- How can I pull information from my loop and divide them seperately?
- How to display elements of different post types?
- Trying to combine multiple WordPress queries
- Fallback if statement based on the number filtered from it
- Query Custom Post Type by Tag
- Fourth page of custom post type archive page does not exist
- Catergory args causing loop not to show
- Cannot exclude particular post from loop of custom post type
- WP_Query() displaying past post / event
- WP Query Conditionally query meta and taxonomy
- How to insert a post from a different post type after every nth post
- Complex Custom Loop with Includes