I just figured out myself how to do it
Take a look at this example:
$args = array();
$args['relation'] = 'OR';
foreach ( $tag_ids as $t ) {
$args[] = array(
'key' => 'afz_entry_tags',
'value' => serialize( strval( $t->id ) ),
'compare' => 'LIKE'
);
}
$query->set( 'meta_query', $args );
I am getting $tag_ids with a normal get_results.
Then i create the first item of the array for meta_query in order to define the OR i need.
Then i iterate through the collection of objects i received from get_results and create as many arrays for the meta_query as i need.
It works like a charm.
Related Posts:
- ACF: How to get users with a ACF flexible content subfield with a specific value AND layout?
- Need to search a custom field (ingredients, one long string per post), but want it to allow phrases/non-exact matches
- Query Posts Via WordPress URL
- Advanced Custom Fields: how do I check to see if a value is set in an field? [closed]
- Using meta query (‘meta_query’) with a search query (‘s’)
- Where are custom field values stored in the database
- ORDER BY custom field value
- Advanced Custom Fields – Get custom fields from parent page
- Can I query custom meta data through WP_Query
- Add custom field to the archive page?
- Add custom fields to search
- SELECT max(meta_value) FROM wp_postmeta WHERE meta_key=’price’… stops working when value is over 999
- Meta Query with AND & OR?
- Filtering a WP_Query meta_query by numeric values isn’t working
- How to position a custom field before the editor
- Display post_object content using Advanced Custom Fields plugin
- Remove old custom field after import
- Unable to get Preview of Uploaded image within a Custom Meta box
- Retrieve custom fields on Categories, using WP-API
- Trying to perform complex custom field query with order by set to field value
- Is there a way to do multiple ordering on a multiple meta_query?
- Order by custom field date?
- Change content before writing to database
- WordPress Search Custom Meta Field Only
- Compare meta_query decimals not working right
- Order Custom post type loop by custom field (datepicker)
- Ordering posts by anniversary using only day and month
- Calling Specific Pages with wp query Part II
- Loop through two different sets of custom fields
- Using Custom Function With Advanced Custom Fields
- automatically set “Featured Image” the same as the og:i that is set in a custom field
- Problem with adding exta field in metabox in custom post type
- Slow meta query with multi meta keys
- Copying Custom Meta Values from existing post to a duplicate post
- Using OR in WP_Query negates the “NOT EXISTS” compare
- How can I query on the year part of a complete date in a custom field?
- Calculate the sum of certain the_sub_fields
- How can I combine meta_query queries?
- Displaying posts with only upcoming dates according their custom field date value
- Displaying Custom Fields on Post with Genesis Child Theme
- Difference between ‘LIKE’ and ‘IN’ in meta queries
- Unable to show ACF’s Image Custom Field properly in Genesis Framework [closed]
- Login & Register & Custom details WITHOUT plugin
- Sorting posts by multiple values, combined
- Send Multiple Custom Field Values Through the URL
- meta_value_num sort glitch
- WP_Query display next custom post from today’s date
- ACF won’t load from a custom JSON location
- Which is best in the following scenario : post_meta vs custom table vs parent/child posts
- WP_Meta_Query causing long-running MySQL queries
- Sorting posts by custom fields in meta_query
- meta_query for a string inside a meta field containing a comma-separated list
- Order by custom field value not working for acf date field
- Show ACF fields only on certain page in the backend
- Update posts after populating ACF field value [closed]
- How can I pass a variable set by ACF to header.php?
- WP Custom Fields Metabox Disappears – ACF plugin issue [closed]
- Transfer self made functions.php custom fields to Advanced Custom Fields [closed]
- Complex WP_User_Query call fails on production server
- Meta query with timestamp using WP_query
- Orderby custom field meta value ASC and then by date DESC
- ACF: How to get the full field name (meta_key) by a field key?
- Dynamically fill a post custom field with post publish date
- How can I store a file in the database in the same way WordPress and ACF do?
- Will loading too many ACF Fields cause slow down?
- How make a custom search on backend in WordPress without plugin?
- WP_User_Query pulling ACF to loop
- How to add a new meta key and assign timestamp to posts
- Get content from pages with same meta_key from Database
- WP 3.1 meta_query for multiple custom field values
- Calling the “wp-link-wrap” pop-up modal
- Print custom field in Query Loop block
- How to add Advenced Custom Fields In Single Post
- How to schedule a custom field value update?
- Order RSS content by an advanced custom field value
- Add new image block, set default class name and update it using Javascript
- Meta Query Not Returning Output Despite Having Matching Values
- Get an advanced custom field after post publish
- How to create a dropdown select of all items in an ACF field group
- How do I have WP_Query match posts based on search parameter OR meta fields? (rather than search parameters AND meta fields)?
- Advanced Custom Fields dynamic update_field
- WooCommerce – Adding Custom Fields To Invoice
- Get posts with same meta value as current post
- Alter main archive, to show posts with meta as last
- Meta Query returns wrong number of posts
- Sort custom post type by multiple custom fields
- Change order of posts
- Meta Query And/Or
- Use meta_query to get title of associated post
- Meta query with multiple custom fields for archives page ordering problem
- filter custom field values $min $max
- Query based on custom fields start and end date
- Ordering posts by custom field named “date” in backend
- Get Data From wp_sitemeta for Multisite network
- Unique meta_key with array value vs repeated meta_key with single values
- get posts where a custom field contains a text
- WP Query – Is this correct?
- Vimeo thumbnails
- Advanced Custom Fields WYSIWYG More tag
- How can I do a variable for meta_query?