• Resolved esalka

    (@esalka)


    Trying to sort search results with get params …&orderby=post_date&order=desc, but nothing changes in results.

    According to “class-asl-searchoverride.php” line 172, plugin should use these params

    } else if ( isset($_GET['orderby']) )

    How can I sort search results by date?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter esalka

    (@esalka)

    How can I sort search results by date/relevance dynamically, not from settings?

    Plugin Author wpdreams

    (@wpdreams)

    Hi,

    You can use the asl_query_args hook. It is not yet documented, it basically gives you access to the query arguments before execution.

    add_filter('asl_query_args', 'asl_query_args_order', 10, 1);
    function asl_query_args_order($args) {
    	$args['post_primary_order'] = 'post_date DESC';
    	return args;
    }

    Best,
    Ernest M.

    Thread Starter esalka

    (@esalka)

    If I use this filter search results are empty 🙁

    Plugin Author wpdreams

    (@wpdreams)

    I may have made a mistake there, try:

    add_filter('asl_query_args', 'asl_query_args_order', 10, 1);
    function asl_query_args_order($args) {
    	$args['post_primary_order'] = 'post_date DESC';
    	return $args;
    }
    Thread Starter esalka

    (@esalka)

    Thanks a lot!

    Plugin Author wpdreams

    (@wpdreams)

    You are welcome 🙂

    I will mark this as resolved then.

    Feel free to rate the plugin if you like it, it is greatly appreciated.

    Best,
    Ernest M.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘orderby=post_date&order=desc doesn’t work’ is closed to new replies.