The issue can be solved with this code :
function my_cpt_query( $query ) {
$myPostObjetField= get_field('cpt1_field_for_cpt2',$post_id,false);
foreach( $myPostObjetField as $post_field_item_value ) {
$ids[] = (int) $post_field_item_value;
}
$query->set( 'post_type', 'CPT2');
$query->set( 'post__in', $ids);
}
add_action( 'elementor/query/13600', 'my_cpt_query' );
Related Posts:
- Filtering a WP_Query meta_query by numeric values isn’t working
- Display Custom Post Type Fields
- Display posts if a custom field value is equal to another custom field value
- Custom Post type and Custom Field WP_Query
- 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
- Custom fields (wp_post_meta) vs Custom Table for large amount of data
- Query based on custom fields start and end date
- Group by custom field value (start and end times)
- WP query_posts group by meta field related
- Create if else for post types in WP_Query ‘post__in’ values
- Filter posts by their related field’s custom field
- Use Custom Field to Display Post Loop
- How to change post featured image using a custom field of category?
- WP_Query: include custom post type only with specific meta value
- 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
- Display custom post type from dynamic custom field
- Query/list all terms and their custom post count
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- Retrieve value of a category’s custom field
- Archive for custom taxonomy lists all posts instead of current taxonomy
- wp_query check if integer exists in custom field’s array
- How can I dynamically add a post to a custom post type which uses a custom field?
- Get latest 3 posts from multiple CPT in one query
- How can I get the number of custom post type posts that have a specific attachment image set?
- Bulk Update Custom Fields for Custom Post Types
- Problem querying Custom post type by custom fields
- Orderby CPT custom fields not working
- Troubles with acf/save_post and WP_Query
- Stuck in Order by more then one
- Meta Query Not Returning Output Despite Having Matching Values
- Including metaboxes from custom post types in global search — continued
- ACF From & To Date Validations
- Query Multiple Custom Posts by Custom Fields
- Using advanced custom fields from one custom post type in another custom post type / using nested shortcodes
- How to render a custom post type template with custom fields using shortcode
- Get Posts by multiple custom fields is not working
- Polylang non-default language ignores tags in WP_Query
- Query Custom Post Type Taxonomy term with multiple parameters
- First custom field value (out of several) displayed twice after query
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- Different Ways to Query Custom Post Types?
- Multiple Frontend Filters Using Advanced Custom Fields
- Integrate Custom Post Type Events into Calendar
- Possible to filter custom post type with multiple meta data?
- Displaying custom field according to date
- WebP Fallback for Inline Background Image in Style Attribute
- pagination not working for category.php (custom post types in categories)
- How to display Related Posts based on number of taxonomy terms matched
- ACF: post query, hide duplicate values [closed]
- 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 make WP_Query not to show irrelevant posts?
- Loop for custom post types filtered by a taxonomy
- How to get a custom type post data when it has a connection with another custom type post?
- WP Query ‘posts_per_page’
- 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
- How to get specific post meta by title or id
- Custom post type, custom taxonomy, query posts only from taxonomy (children of)
- Getting a custom post’s custom field based on another custom post’s custom field select
- How to inherit field value from parent post into in child / sub post
- WP_Query orderby not work with meta_key
- Having Issue on Ordering CPT by Custom Field In Custom WP Query
- Pagination not working on custom query on a page
- Custome fields not displayed
- find custom post type post by searching its custom field with my string
- FacetWP paging custom wp_query
- posttype and custom fields on multisite
- 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
- Sum and count of custom field values
- Custom Post type loop with ACF not displaying properly
- Can’t change posts per page in WordPress Post Type Query
- postsperpage value not being applied
- Custom post types, disable fields
- Best way to create a search for custom post type by custom field values
- Incorrect ordering of custom post type based on time
- Get A Custom Field From A Custom Taxonomy Of A Custom Post Type [closed]
- Using WP meta query to show custom post types by a start and finish date
- Cache issue with WP_Query and custom field filtering
- Display Posts Query with IF function
- Excerpt length: get first paragraph
- How do I list a custom field and custom taxonomies for each result in a loop?
- Custom Post Type Query W/Category Dropdown
- Find Posts based on Child Post value
- Custom Post Type ‘Event’: Chronological list of recurring events from meta_values in array
- Sorting the Loop by Taxonomy Value
- Custom Query: Multiple CPTs and a taxonomy filter
- 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?
- ACF – Retrieve custom taxonomy from a relationship field
- Custom wp-query display post only today
- Custom Form / Search with Custom Post Type Data
- WP Query from two Custom Post type fields as statement