Filtering – Edit Query Arguments

Forums › Forums › Search & Filter Pro › Filtering – Edit Query Arguments

Tagged: 

Viewing 4 posts – 1 through 4 (of 4 total)
  • Anonymous
    #89484

    Hello,

    I am having some issue with the filtering. I am trying to add an argument that will list my posts in order of date in descending order. Here is what I’ve come up with:

    function filter_function_name( $query_args, $sfid ) {
    	
    	//if search form ID = 225, the do something with this query
    	if($sfid==334)
    	{
    		$query_args = array(
    	'meta_key' => 'webinar_date',
    	'orderby'=> 'meta_value',
    	'order'	=> 'DESC'
            );
    	}
    	
    	return $query_args;
    }
    add_filter( 'sf_edit_query_args', 'filter_function_name', 20, 2 );
    

    But it comes up with no result with the above. Could you please help me with this.

    Thanks in advance

    Anonymous
    #89666

    Hello, does anyone have any ideas. Really need some help..

    Trevor
    #89774

    Sorry, whilst I can sometimes work on weekends, our official hours are UK time 10am to 5pm Monday to Friday (excluding National Holidays). By replying to your own thread you bumped it further down the queue, otherwise it would have been answered hours ago.

    This webinar_date is a meta key and not the post date? In the form, there is a sort order option on the Posts tab, where you can specify a meta key as the sort order.

    Did you try that first? In what format is the date saved into the database? This will be key in determining of a sort will work as expected. So-called ACF format is required (so today would be 20170213).

    Anonymous
    #89901

    Hi Trevor, no problem at all, thanks for your reply.

    I did as you said and ordered by meta value ‘webinar_date’ and sure enough it works perfect. Thanks you very much.

    This plugin is awesome!

Viewing 4 posts – 1 through 4 (of 4 total)
Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.