• Resolved LesTexas60

    (@lestexas60)


    I like the concept of adding a filter using the New Query ID. I use this with Elementor Post widget all the time to set the Category and the Start and End date so the Posts will auto show. I tried adding the same code to Prime Slider but nothing is being filtered. It shows all posts and doesn’t even filter the Category. The code below should filter based on the Category bing Cat1 and it also checks that the current date is between the start and End date fields, they are ACF fields. Any suggestions are appreciated.

    add_action('elementor/query/test33', function($query){ 
    	$query->set('category_name', 'cat1');
        $query->set('orderby', 'title');
        $query->set('order', 'ASC');
        $meta_query[] = [
            
            [
                'key' => 'start_date',
                'value' => date('Y.m.d'), //date format set in ACF
                'compare' => '<=',
                'type' => 'DATE'
            ],
    		[
                'key' => 'end_date',
                'value' => date('Y.m.d'), //date format set in ACF
                'compare' => '>=',
                'type' => 'DATE'
            ],
        ];
        $query->set( 'meta_query', $meta_query );
    	
    });
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Maudud Hossain

    (@maudud)

    Hello @lestexas60,
    Thanks for your idea.
    We have already a custom query ID field( https://prnt.sc/tbbAdBXct0pl ). You can filter any item by this query ID.

    Hope you understand.

    Regards,
    Maudud Hossain

    Thread Starter LesTexas60

    (@lestexas60)

    I understand you already have the field but my point is, it doesn’t work. I use Snippet plugin to create the code for that field and then add the snippet name to the Custom Query field. Elementor has the same option in their post widget. The code above I added to Post widget and it works but when I add the snippet to your plugin, the filter doesn’t work. Do you have any videos or instructions about how to use your Custom Query? Maybe just something simple like how would I filter by Category using the Custom Query.

    Plugin Contributor Maudud Hossain

    (@maudud)

    Hello @lestexas60,
    Thanks for your suggestions for making a tutorial. We will make a tutorial soon.
    Our Prime Slider hook name is “prime_slider”. Please rename the hook name.

    Just edit your first line as:
    add_action(‘prime_slider/query/test33’, function($query){

    Regards
    Maudud Hossain

    Plugin Author Shahidul Islam

    (@bdkoder)

    Hello @lestexas60,
    We wish you got the solution, if not you may let us know in our live chat support system or in this wp support system.

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘New Query Feature?’ is closed to new replies.