<?php
// // rest of snippet code here
// function my_query_by_post_types( $query ) {
// if ($query->get('post_type') === 'post') { // Replace 'post' with your desired post type
// $args = array(
// 'posts_per_page' => 5, // Set the number of posts you want to display
// // Add any other query parameters or modifications you need
// );
// $custom_query = new WP_Query($args);
// if ($custom_query->have_posts()) {
// $query->set('post__in', $custom_query->post->ID);
// $query->set('orderby', 'post__in');
// }
// wp_reset_postdata();
// }
// }
// add_action( 'elementor/query/my_practice_query_123', 'my_query_by_post_types' );
add_action( 'elementor/query/my_practice_query_123', function( $query ) {
// Here we set the query to fetch posts with
// post type of 'custom-post-type1' and 'custom-post-type2'
if ($query->get('post_type') === 'directory') { // Replace 'post' with your desired post type
$custom_query = new WP_Query(array(
'posts_per_page' => 5, // Set the number of posts you want to display
// Add any other query parameters or modifications you need
));
// Modify the main query with the custom query
$query->set('post_type', $custom_query->get('post_type'));
$query->set('posts_per_page', $custom_query->get('posts_per_page'));
$query->set('post__in', $custom_query->get('post__in'));
// Add any other query modifications as needed
// Reset the custom query to avoid interference with other queries
wp_reset_postdata();
}
//$query->set( 'post_type', [ 'directory', 'cocktails', 'spritz' ] );
} );
// function custom_elementor_post_query($query) {
// if ($query->get('post_type') === 'directory') { // Replace 'post' with your desired post type
// $custom_query = new WP_Query(array(
// 'posts_per_page' => 5, // Set the number of posts you want to display
// // Add any other query parameters or modifications you need
// ));
// // Modify the main query with the custom query
// $query->set('post_type', $custom_query->get('post_type'));
// $query->set('posts_per_page', $custom_query->get('posts_per_page'));
// $query->set('post__in', $custom_query->get('post__in'));
// // Add any other query modifications as needed
// // Reset the custom query to avoid interference with other queries
// wp_reset_postdata();
// }
// }
// add_action('elementor/query/my_practice_query_123', 'custom_elementor_post_query');