Currently your meta query is exclusive and you need to make it inclusive. For example, you can save always the meta field show_in_news
for match-report custom post type, even when the value is false
. Then, you can include posts if custom show_in_news
doesn’t exist (standard posts) or if it exists and it is "true"
for custom post type:
$queryArgs = array(
"post_type" => array( "post", "match-report" ),
"meta_query" => array(
"relation" => "OR",
array(
"key" => "show_in_news",
"compare" => "NOT EXISTS",
),
array(
"key" => "show_in_news",
"value" => "true",
),
),
);
This should do the job.
Related Posts:
- Filtering a WP_Query meta_query by numeric values isn’t working
- Display posts if a custom field value is equal to another custom field value
- WP_Query order by custom field, then randomly order some of results
- Query custom post type with ACF Date
- Order Custom Post Type by Custom Field Value
- Query based on custom fields start and end date
- Group by custom field value (start and end times)
- Create if else for post types in WP_Query ‘post__in’ values
- Filter posts by their related field’s custom field
- Display ACF object field data using Elementor Custom Query
- WP_Query orderby custom field then post_date in one query
- how to filter by last name for custom post
- Sorting a query by custom field date
- How can I generate a RSS feed based on a custom WP_Query?
- Filter a custom field based on selection of another custom field (ACF) [closed]
- ACF Relationships in Custom Post Type Permalink
- Search Custom Post Type with all meta attached?
- WordPress Search documentation: how to improve search query using taxonomy terms, custom meta fields?
- How to sort CPT by custom meta value (date), and return posts month by month
- Query by 2 values of a repeater ACF field
- Comparing timestamps in meta query doesn’t work
- Display two post types ordered by two custom fields
- Get post info inside modal window?
- Having trouble with custom date field for CPT query (WordPress)
- ACF Upload Image in repeater from front-end with custom form? – add_post_meta()
- Sort by two dates. Default entry date and custom field if present
- Get Custom Field Values by Another Custom Field in WordPress
- Query Custom Post Types by date (custom field) range
- Conditional to modify query results
- Filtering by Post Meta Custom Fields – Performance
- WP Query—Relationship between two custom post types and their fields
- Get all Posts If has same custom field values in Posts
- Custom Post Types not showing, custom WP_Query
- Display multiple custom post types and sort them chronological by one of their fields
- How to change post featured image using a custom field of category?
- WP_Query orderby modified to include custom meta changes
- WordPress custom loop filter by meta_key and value with serialize data
- Returning a list of custom post types excluding those without a specific meta_value
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- Retrieve value of a category’s custom field
- wp_query check if integer exists in custom field’s array
- Stuck in Order by more then one
- Meta Query Not Returning Output Despite Having Matching Values
- How to render a custom post type template with custom fields using shortcode
- Get Posts by multiple custom fields is not working
- Query Custom Post Type Taxonomy term with multiple parameters
- Custom fields (wp_post_meta) vs Custom Table for large amount of data
- Multiple Frontend Filters Using Advanced Custom Fields
- Integrate Custom Post Type Events into Calendar
- Displaying custom field according to date
- Redirect to another page using contact form 7? [closed]
- Why is my WP Query not returning first result’s post meta?
- DIsplaying URL of custom field in last post of certain taxonomy && post type
- How to get a custom type post data when it has a connection with another custom type post?
- Display post from a date range from custom field
- post_per_page ignored in WP_Query
- List of users that clicked a ‘Join’ button at single post
- Getting a custom post’s custom field based on another custom post’s custom field select
- WP_Query orderby not work with meta_key
- Having Issue on Ordering CPT by Custom Field In Custom WP Query
- Custome fields not displayed
- How do I get_the_postID() for a custom post that uses ACF repeater field?
- How do I replace the post title with a custom field?
- Display custom post type for specific user
- Custom Post type loop with ACF not displaying properly
- Custom post types, disable fields
- Get A Custom Field From A Custom Taxonomy Of A Custom Post Type [closed]
- Excerpt length: get first paragraph
- WP query_posts group by meta field related
- Having a repeating custom field in admin custom post type, what I’d go better with, for DB’s sake? ACF repeater or query a different post type?
- Custom Form / Search with Custom Post Type Data
- WP Query from two Custom Post type fields as statement
- Using ACF values in nested WP queries for CPT with date values in the past
- WP_Query get always custom post_type for first
- Display Custom Field or Custom Taxonomy in front page /post/product
- How to access repeater field of a custom field?
- How can I fetch all the dates from custom fields from various different custom post types and show / list them at one place in ascending order?
- meta query multiple values for the same key
- Sort custom post archives by a meta value from a different custom post type?
- filter using custom fields
- Custom post types – meta_query: search lesson which starts sooner
- How do I display specific custom posts, and how do I edit a post’s singular page?
- Fixed custom fields depending on posttype/category
- Calling specific page with wp query
- Selecting posts older than the current Unix epoch timestamp
- WP_Query get posts where post_name is empty
- If i have custom post type with 5 custom fields do i have to create a new loop to reference each one?
- Query recent posts by author
- 404 on Pages for Custom Post Type & Query_Posts
- How to show animal lineage/pedigree in WordPress?
- Querying meta values within an array
- Filter Custom post type by another Custom post type
- Show Posts in Vertical Tabs with Scrollbar
- Retrieve a post with its ACF repeater fields in wordpress
- Is it possible to specify a time interval (from, to) in ACF with date picker, or other custom field?
- WordPress custom field sorting, weird behavior: the latest post is at the end
- Sort CPT by taxonomy AND THEN by custom field
- WP Query + custom fields: How to query event posts from the current date backwards 6 months and organize it month by month?
- Post object GUID adding http:/
- Query order by a numeric ACF field