-
-
Save MarieComet/7ff001750a5e8a0ec6a724fcb4c6ccdd to your computer and use it in GitHub Desktop.
| <?php | |
| function elementor_posts_widget_multiple_post_types( $element, $args ) { | |
| $element->update_control( | |
| 'posts_post_type', // control ID | |
| [ | |
| 'type' => Elementor\Controls_Manager::SELECT2, | |
| 'multiple' => true, | |
| ] | |
| ); | |
| } | |
| add_action( 'elementor/element/posts/section_query/after_section_end', 'elementor_posts_widget_multiple_post_types', 10, 2 ); |
@TroopekYT yes, you don't need to create a new theme.
Thanks a lot it worked!
any chance you could reqrite this for the new loop grid?
Hi @nodex4.
What is the new loop grid please ?
Any doc ?
@MarieComet - I assume Nodex means this: https://elementor.com/help/loop-grid/
This would be very helpful for me too.
Exactly, i mean that one right there.
+1 for extending this to the loop grid builder, would be super helpful!
Loop Carousel:
function elementor_loopcarousel_widget_multiple_post_types( $element, $args ) { $element->update_control( 'post_query_post_type', // control ID [ 'type' => Elementor\Controls_Manager::SELECT2, 'multiple' => true, ] ); } add_action( 'elementor/element/loop-carousel/section_query/after_section_end', 'elementor_loopcarousel_widget_multiple_post_types', 10, 2 );
Loop Grid
function elementor_loopgrid_widget_multiple_post_types( $element, $args ) { $element->update_control( 'post_query_post_type', // control ID [ 'type' => Elementor\Controls_Manager::SELECT2, 'multiple' => true, ] ); } add_action( 'elementor/element/loop-grid/section_query/after_section_end', 'elementor_loopgrid_widget_multiple_post_types', 10, 2 );
Loop Carousel:
function elementor_loopcarousel_widget_multiple_post_types( $element, $args ) { $element->update_control( 'post_query_post_type', // control ID [ 'type' => Elementor\Controls_Manager::SELECT2, 'multiple' => true, ] ); } add_action( 'elementor/element/loop-carousel/section_query/after_section_end', 'elementor_loopcarousel_widget_multiple_post_types', 10, 2 );Loop Grid
function elementor_loopgrid_widget_multiple_post_types( $element, $args ) { $element->update_control( 'post_query_post_type', // control ID [ 'type' => Elementor\Controls_Manager::SELECT2, 'multiple' => true, ] ); } add_action( 'elementor/element/loop-grid/section_query/after_section_end', 'elementor_loopgrid_widget_multiple_post_types', 10, 2 );
Thanks, This code works perfectly
Loop Carousel:
function elementor_loopcarousel_widget_multiple_post_types( $element, $args ) { $element->update_control( 'post_query_post_type', // control ID [ 'type' => Elementor\Controls_Manager::SELECT2, 'multiple' => true, ] ); } add_action( 'elementor/element/loop-carousel/section_query/after_section_end', 'elementor_loopcarousel_widget_multiple_post_types', 10, 2 );Loop Grid
function elementor_loopgrid_widget_multiple_post_types( $element, $args ) { $element->update_control( 'post_query_post_type', // control ID [ 'type' => Elementor\Controls_Manager::SELECT2, 'multiple' => true, ] ); } add_action( 'elementor/element/loop-grid/section_query/after_section_end', 'elementor_loopgrid_widget_multiple_post_types', 10, 2 );
This is fantastic, thank you!!!
Any chance this would work with the new live search widget as well?
Loop Carousel:
function elementor_loopcarousel_widget_multiple_post_types( $element, $args ) { $element->update_control( 'post_query_post_type', // control ID [ 'type' => Elementor\Controls_Manager::SELECT2, 'multiple' => true, ] ); } add_action( 'elementor/element/loop-carousel/section_query/after_section_end', 'elementor_loopcarousel_widget_multiple_post_types', 10, 2 );
Loop Gridfunction elementor_loopgrid_widget_multiple_post_types( $element, $args ) { $element->update_control( 'post_query_post_type', // control ID [ 'type' => Elementor\Controls_Manager::SELECT2, 'multiple' => true, ] ); } add_action( 'elementor/element/loop-grid/section_query/after_section_end', 'elementor_loopgrid_widget_multiple_post_types', 10, 2 );This is fantastic, thank you!!! Any chance this would work with the new live search widget as well?
Sure! Try this:
function elementor_search_widget_multiple_post_types( $element, $args ) { $element->update_control( 'search_query_post_type', // control ID [ 'type' => Elementor\Controls_Manager::SELECT2, 'multiple' => true, ] ); } add_action( 'elementor/element/search/content_section_query/after_section_end', 'elementor_search_widget_multiple_post_types', 10, 2 );
This is fantastic, thank you!!! Any chance this would work with the new live search widget as well?
Sure! Try this:
function elementor_search_widget_multiple_post_types( $element, $args ) { $element->update_control( 'search_query_post_type', // control ID [ 'type' => Elementor\Controls_Manager::SELECT2, 'multiple' => true, ] ); } add_action( 'elementor/element/search/content_section_query/after_section_end', 'elementor_search_widget_multiple_post_types', 10, 2 );
I tried tweaking your previous code myself, but obviously messed up something - this snippet however works like a charm! Thank you SO much!
is it enough if i addd this to my theme's function.php file or should I make a new one?