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
- 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
- How to show posts from multiple post types in a single loop? And display them separately on the same template
- Can’t sort order of wp_query with 2 meta keys
- Comparing timestamps in meta query doesn’t work
- Display two post types ordered by two custom fields
- Query Custom Post by Category
- WP_Query and using a variable for ‘cat’=> in the args array = WP Bug?
- Separate Posts and Custom Post Type in Custom Taxonomy archive template
- Why does using WP_Query inside a shortcode in an elementor page cause the arguments for WP_Query to get malformed?
- Lists Posts from CPT that match the Title of the Page
- Filtering by Post Meta Custom Fields – Performance
- Is it possible to apply a meta_query to one specific post type in a query with multilple post types?
- Remove duplicated values from a loop
- is there a way to retrieve posts that do not have a featured image assigned?
- WP_Query | ‘post_type’ doesn’t work
- How to connect two custom post types with nested loops
- Filter by custom taxonomy slug on a custom post type
- Can I create a loop with multiple post types and specify different $args for each post type?
- Setting proper query for multiple custom admin filters
- WP_Query orderby modified to include custom meta changes
- Returning a list of custom post types excluding those without a specific meta_value
- 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?
- Problem: wp_query outputs all images on site
- How can I group posts by months and years?
- Multiple Custom Post Type queries, how to DRY it up
- 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
- Getting a custom post’s custom field based on another custom post’s custom field select
- Pagination not working on custom query on a page
- Trying to add a class to post links
- 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
- Two queries – one with checkbox ticked, one without – comparing meta_query
- Custom Post Type Query W/Category Dropdown
- Multiple custom post type queries causing wrong post types to be grabbed in taxonomy + single templates?
- Custom post type pagination error
- Query for specific taxonomy that executes a particular loop depending on volume of posts?
- How to order query results based on if a custom field has been populated, then the order by the date of the post?
- Page that lists publications by classifying them by taxonomy
- posts_per_page in custom WP_Query does not override “Reading” settings?
- Pin posts to top of custom loop
- Filtering posts based on three taxonomies
- Order posts alphabetically with numbers but some of the posts has numbers in the title
- SEARCH QUERIES – REVERSE OUTPUT
- Error in the page of a CPT file in WordPress
- ACF meta_key and meta_value break loop
- meta query multiple values for the same key
- Sort custom post archives by a meta value from a different custom post type?
- post_type incorrect for custom post type
- Skip latest 3 posts from loop
- Staggering featured post using ‘sticky’
- Custom post types – meta_query: search lesson which starts sooner
- post type => ‘any’ not applied my custom queries
- Mix Facebook and Twitter feed into custom posts
- How to get the posts that my following users are liked?
- Sort loop by custom field from different post type
- Querying, storing, and using data from 2 separate custom post types
- Strange behavior on WP_query
- How To Loop Through list with Custom Post Types
- Custom Post Type + Category archive
- display news with pictures 3 small and one large (loop)
- Post data in separate divs with incrementing class using WP_Query
- Selecting posts older than the current Unix epoch timestamp
- How to display elements of different post types?
- Trying to combine multiple WordPress queries
- 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
- Custom Post Type + Custom Meta Query Not Showing 2012 Posts
- 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
- How can I show posts with the same tag?
- WP_Query() displaying past post / event
- WP Query Conditionally query meta and taxonomy
- Query Multiple Post Types and Paginate Newly Created List
- SOLVED: Shortcode to display Divi project filtered by tag in WP Query loop