An easy query like the following should work for you:
<?php
$_query = new WP_Query( array(
'post_type' => 'post',
'posts_per_page' => -1,
'post_status' => 'publish',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'key1'
),
array(
'key' => 'key2'
),
),
) );
?>
Note the 'relation'=>'OR'
in meta_query
.
More at:
Related Posts:
- Get all image from single page using this query
- simple sql query on wp_postmeta very slow
- How to Use Wildcards in $wpdb Queries Using $wpdb->get_results & $wpdb->prepare?
- wordpress query – orderby child post date
- Add multiple value to a query variable in WordPress
- Compare two numeric custom fields
- wp_dropdown_categories with multiple select
- How to tune search argument in WP_Query to show only exactly the same results?
- Custom query filter not working on woocommerce category page
- How to delete a transient on post/page publish?
- How to get my loop to pull posts into three columns
- Custom $wpdb Query for Custom Post Type by Category
- Can’t pass table to $wpdb->prepare
- WordPress creating excessive joins on meta_query with search
- How to display liked posts of current user in wordpress?
- Date query year and month OR just year
- Remove Unnecessary Mysql Query
- Grouping related postmeta data via SQL query
- How to remove duplicate query on page load or make them cacheable
- Slow meta_query with about 4 milion record on wp_postmeta
- wpdb::prepare() isn’t working
- How can I apply a meta query for a single custom post type in the main query?
- WP Query Sort by meta value (date)
- mySQL query. ORDER BY meta_key
- Disable the MySQL query in the main query
- Huge amount of queries on my site
- Strange string in console from wpdb query
- Using pre_get_posts to target a query in the sidebar
- How can I get the query that would be run for the archive page?
- Query metas (and not : query posts by metas)
- Select query for a login
- What’s wrong with my $wpdb prepare?
- How do I use get_query_var() within plguin code
- How to display related posts by same publish date?
- Get post according to current taxonomy
- Ordering by a metadata subfield in WordPress?
- Alter query with posts_clauses to retrieve NULL values last
- Query based on title, with ‘compare’ => ‘IN’
- wpdb print all post meta
- Issue with using add_rewrite_rule() for post querying custom fields
- Plugin will sort users by usermeta
- How to write: $wpdb->update having WHERE NOT value pair in the array
- Query posts according to specific post meta values
- wpdb COALESCE won’t work
- empty query breaks other queries
- Problem in exploding the_content to array
- Custom SQL Query passing array to WHERE p.id
- Query does not return content
- What is wrong with my wp query, cant exclude the category that i want
- how to insert missing tags into the posts through mySQL?
- Query posts dynamic date range
- Parse query filter in wordpress and relation
- How to write update query in WordPress to expire transients
- Query Nickname rather than Display Name in custom Woocommerce plugin
- Get previous posts list
- how to replace old DW site with new WP site? [closed]
- WordPress SQL query to tag all posts containing a specific word on title
- get_post_meta with WP_query
- Order terms by count – missing terms
- Querying Advanced Custom Fields
- How to rearrange a pool of posts joined using two queries?
- wpdb update multiple row?
- List WordPress Post and Related Attachments outside of a post page
- Can I include get_posts in this array?
- Custom query Custom-Post-Types creates error
- Formatting a date/time returned from a custom $wpdb query
- Problem on displaying the results on my query
- Rewrite rule for query params
- Improve performance of slow query
- WordPress search in modified post title
- Hook into the Admin Dashboard and redirect users
- WordPress query: merge meta key (number) values and sort
- Displaying data from custom table
- SEO friendly query vars
- Prevent versioning for .woff (font) files
- Orderby event date (if it exists) or post date (if it doesn’t) – how to reorder posts based on meta value OR date
- Is there any way to get all custom posts and all custom terms with it’s meta in few queries?
- OR condition not working
- Query not returning child posts for any parent post ID
- Use $wpdb->get_results with filter based on array
- Add Hook for clearing transient when post is added
- Archive query not working correctly
- Custom MySQL Query for Post and Post Meta
- Displaying popular posts
- How to have more post in a page than in your home page
- Find all posts via SQL beginning with A of type B
- Show links to child pages on both parent AND child pages
- Modify Global Posts Plugin
- How to reference same column name but different table in custom db query
- Retrieving custom field array value through db query
- SQL Query : how copy all tags of post into their post content in wordpress by sql query
- How to add multiple values with add_query_arg?
- 3 queries to update WordPress
- How do I troubleshoot Maximum execution time of 60 seconds exceeded in updating a Media File?
- update $wpdb one query
- Admin Post List table Query filtering “WHERE” for custom post type
- Ascending & descending posts on same page with IF statement
- Prevent executing query for wp_global_styles
- How to use a dynamic term id for the query block
- Meta Query compare with LIKE pulls similar post types: 55 and 155, and 1,155