Home > Software design >  Custom Query Filter in Elementor doesn't work
Custom Query Filter in Elementor doesn't work

Time:09-30

I am trying to use the custom query filter in Elementor, but even the simple Elementor example doesn't work for me. I don't know if I'm doing something wrong. Here is my code in functions:

    function query_filter($query){
    $query -> set('post_type', 'ship');
};

    add_filter('elementor/query/my_query', 'query_filter');

And I have this name set in Elementor: Custom query id Elementor

I'm just trying to show all custom post types 'ship' but it doesn't work. I am not receiving any error in PHP or in JS on the console.

PD: The Query ID is the only one I have so it is unique.

CodePudding user response:

In case is usefull for someone: I found the problem: In elementor when I select 'SOURCE' if I set 'current query' it just show the actual page. I need to select any other option in order to be able to user the Custom Query.

Also try with with both:

add_filter('elementor/query/my_query', 'query_filter'); 
add_action('elementor/query/my_query', 'query_filter');
  • Related