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 do you get the count of posts in an archive page?
- Mixing regular and custom post types (with meta_query) on home page
- How to use a custom post type as front page?
- WP_Query() show posts that end later than today
- WP_Query orderby custom field then post_date in one query
- Filtering a WP_Query meta_query by numeric values isn’t working
- Display several random posts, but make sure a condition is met
- WP_Query to loop a Custom Field, Custom Post Types do not show
- Retrieving 3 latest post from each of 5 different custom post types
- Using Query Posts With Multiple Post Types And A Taxonomy
- WP_Query on custom post type not displaying, multiple loops & get_template_part
- Using new WP_Query in shortcode in a custom field causes the main post content to not display
- How to show posts from multiple post types in a single loop? And display them separately on the same template
- How to create posts (not post template) to be displayed on projects page?
- Can’t sort order of wp_query with 2 meta keys
- 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
- query order by date on custom type: wrong order
- Should unaltered default loop/query return a list of custom posts belonging to a custom taxonomy?
- Query for posts in 2 taxonomies
- 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?
- 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?
- Why is this query not working? (Standard posts + custom post type)
- WP Query with categories only shows one post and ignores the category
- Problem: wp_query outputs all images on site
- Configuring a meta query with multiple post types that have the same relationship on a single page
- Possible to filter custom post type with multiple meta data?
- pagination not working for category.php (custom post types in categories)
- Query based on custom fields start and end date
- Wrapping x posts in html without leaving empty html
- 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?
- Multiple Custom Post Type queries, how to DRY it up
- Custon Content within WordPress Loop
- Loop increase number
- Using wp_query to modify the loop in index.php for a CPT
- Custom WP_Query doesn’t display all posts
- Query & the_content() is showing in the header
- WP_query – Filter by tax_query and meta_query using multiple select
- 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
- Pagination not working on custom query on a page
- find custom post type post by searching its custom field with my string
- WP_Query of custom post type sorted by meta_key has unexpected results
- display posts of custom post type with custom taxonomy
- Trying to add a class to post links
- 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
- List all Custom Post Type posts excluding certain Taxnomy term
- Query Posts, order by meta value
- WP_Meta_Query object with conditionals
- 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?
- Using WP meta query to show custom post types by a start and finish date
- Two queries – one with checkbox ticked, one without – comparing meta_query
- How to retrive Custom Post Type Meta Fields in Custom WP_Query
- next_posts_link returns same content of 1st page
- Custom loop won’t work, can’t find problem
- Custom post-type’s pagination not working in category.php
- loop through custom post-type with two meta_keys
- Querying meta values within an array
- Query Custom Post Type by Tag
- Fourth page of custom post type archive page does not exist
- Custom Post Type + Custom Meta Query Not Showing 2012 Posts
- Catergory args causing loop not to show
- Cannot exclude particular post from loop of custom post type
- How do I correctly query posts from a post ID?
- display custom post type from register taxonomy
- How to exclude certain portfolios from a loop
- Custom post type and have_posts() return empty result
- Order Wp Query by earliest of 3 dates meta query
- How can I show posts with the same tag?
- 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
- WP_Query not using relation key as expected and not producing any results
- Query Multiple Post Types and Paginate Newly Created List
- WP Query filtering by custom category not showing all relevant posts
- SOLVED: Shortcode to display Divi project filtered by tag in WP Query loop
- author archives, showing all custom post types, problem on pagination