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
- Using meta query (‘meta_query’) with a search query (‘s’)
- Where are custom field values stored in the database
- ORDER BY custom field value
- Add custom field to the archive page?
- Filtering a WP_Query meta_query by numeric values isn’t working
- How to position a custom field before the editor
- 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?
- Ordering posts by anniversary using only day and month
- Calling Specific Pages with wp query Part II
- 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
- Calculate the sum of certain the_sub_fields
- Displaying posts with only upcoming dates according their custom field date value
- Difference between ‘LIKE’ and ‘IN’ in meta queries
- Login & Register & Custom details WITHOUT plugin
- Sorting posts by multiple values, combined
- Send Multiple Custom Field Values Through the URL
- WP_Query display next custom post from today’s date
- ACF won’t load from a custom JSON location
- WP_Meta_Query causing long-running MySQL queries
- 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?
- 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
- 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
- Meta Query Not Returning Output Despite Having Matching Values
- 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
- 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
- Use meta_query to get title of associated post
- get posts where a custom field contains a text
- WP Query – Is this correct?
- Vimeo thumbnails
- Advanced Custom Fields WYSIWYG More tag
- Avoiding ACF get_field and returning to core WordPress function
- Walker class for sub-menu with ACF fields
- Query post by date (stored custom field meta as yyyymmdd) and differentiate across 12 months
- How to copy data from a custom field to the post_content?
- WordPress creates new lines in postmeta table on post update
- Meta_query ‘compare’ => ‘LIKE’ not working?
- Diamond question mark in text after migrating content
- Retrive Image URL of Custom Fields in Theme
- How to Pass values to Custom Field through PHP in WordPress Posts?
- Advanced Custom fields not available yet during publish_page action
- Custom field Search with Relavanssi
- Best way to sort estates and query them (for rent? yes/no. contains office space? yes/no)?
- Rewrite comment form post ID on submit
- ACF field group not showing in page
- What am I missing in this Code Block?
- Making WP_Query limit results by date before today where date is a meta_query
- How to show ACF fields in Gridbuilder custom block
- multiple meta_query and orderby question
- ACF: How to query for a given value count of an array like field? (e.g.: How many rows has a `flexible_content` field?)
- get_field values for each post on home page using wp_add_inline_style
- Shortcode for Custom Field of Media Attachment (to use with Featured Images)
- Filtering posts by ACF meta query
- Weird custom fields data lost
- Why does my numeric meta query work only on one meta key and not the other?
- meta_query to check all custom fields
- Retrive acf fields in publish_post action for wp_mail
- How to delete attachments associated with custom field type when post property changes? [closed]
- Page template is missing fields or is invalid when I updating the template
- Using ACF Custom Field value in a URL with do_shortcode() [closed]
- display Flexible Fields from options
- WordPress taxonomy child image
- Filter and display a specific custom field value [closed]
- Display different category template if custom field is checked
- How to filter post using custom feild value in shortest and longest duration?
- How to Order Posts by Custom Fields?
- Meta_query not filtering posts
- Get custom field from other post in carousel
- I want to add a custom field in the rss title of each post, but don’t want it to be shown on the site
- Advenced custom fields auto fill problem
- Dynamic background image used in css after selector
- How to get all specific fields from one ACF Group?
- save all acf options in one meta_value [closed]
- WP Query Args – search by meta_key or title
- acf field repeater link don’t work
- ACF in radio button cf7