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
- Using meta_query, how can i filter by a custom field and order by another one?
- WP_Query orderby custom field then post_date in one query
- how to filter by last name for custom post
- Filtering a WP Query result
- Filter a custom field based on selection of another custom field (ACF) [closed]
- WordPress Search documentation: how to improve search query using taxonomy terms, custom meta fields?
- Using Query Posts With Multiple Post Types And A Taxonomy
- How to get the parent’s taxonomy?
- Using new WP_Query in shortcode in a custom field causes the main post content to not display
- WordPress query by multiple Custom fields and order by date
- Get post info inside modal window?
- Query not returning CPT posts
- WP Query group/order by category name
- Unable to display multiple post types in same query (WPML WP_Query)
- Query current and future events, ordered by begin date
- Having trouble with custom date field for CPT query (WordPress)
- Quickest way to get last or oldest post date – WP Query
- ACF Upload Image in repeater from front-end with custom form? – add_post_meta()
- Separate Posts and Custom Post Type in Custom Taxonomy archive template
- Query Custom Post Types by date (custom field) range
- Custom query shows custom post types in trash
- Filtering by Post Meta Custom Fields – Performance
- WP Query—Relationship between two custom post types and their fields
- How to dynamically attach pictures to a carousel
- Remove duplicated values from a loop
- How to insert content from another Custom Post type into Post?
- 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
- Returning a list of custom post types excluding those without a specific meta_value
- Query/list all terms and their custom post count
- 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
- Polylang non-default language ignores tags in WP_Query
- Displaying custom field according to date
- How to display Related Posts based on number of taxonomy terms matched
- ACF: post query, hide duplicate values [closed]
- How to make WP_Query not to show irrelevant posts?
- 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
- Pagination not working on custom query on a page
- Custome fields not displayed
- How do I get_the_postID() for a custom post that uses ACF repeater field?
- Display custom post type for specific user
- Custom post types, disable fields
- Best way to create a search for custom post type by custom field values
- Display Posts Query with IF function
- Excerpt length: get first paragraph
- Custom Post Type Query W/Category Dropdown
- Sorting the Loop by Taxonomy Value
- Custom Query: Multiple CPTs and a taxonomy filter
- Custom wp-query display post only today
- WP Query from two Custom Post type fields as statement
- custom post type and a “sticky” position taxonomy
- WP Admin Dropdown List Filter for custom (ACF) field on custom post type(s)
- 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?
- 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
- Query the title of the page to show posts with matching category in the loop
- How do I display specific custom posts, and how do I edit a post’s singular page?
- Fixed custom fields depending on posttype/category
- Automatically convert standard posts with custom fields to custom post types
- Main site single-property.php design, as homepage of a multisite
- Get month and day from a Date Picker custom field
- Calling specific page with wp query
- display news with pictures 3 small and one large (loop)
- Selecting posts older than the current Unix epoch timestamp
- Query Distinct Taxonomies of Custom Post Type
- Custom post type blog pagination conflict
- WP_Query get posts where post_name is empty
- Query recent posts by author
- Querying meta values within an array
- How to grab data (titles, thumbnails and custom fields) from multiple posts to populate a new array efficiently?
- Filter Custom post type by another Custom post type
- How do I correctly query posts from a post ID?
- How to exclude certain portfolios from a loop
- 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
- Assign a tag to custom post type using a query
- Sort CPT by taxonomy AND THEN by custom field
- Post object GUID adding http:/
- Query order by a numeric ACF field