Forums Forums Search & Filter Pro Custom `posts_orderby` for a list of people

Viewing 2 posts - 1 through 2 (of 2 total)
  • Anonymous
    #214790

    Hi,

    Please can you advise on how I might use this custom posts_orderby function to order the results on page load, and when it is searched and filtered (via AJAX)

    `
    function posts_orderby_lastname ($query) {
    $orderby_statement = “RIGHT(post_title, LOCATE(‘ ‘, REVERSE(post_title)) – 1) ASC”;
    return $orderby_statement;
    }

    add_filter( ‘posts_orderby’ , ‘posts_orderby_lastname’ );
    `

    Is there anyway to modify the order of the id’s that are stored in cache for the results?

    Trevor
    #214793

    You want this to be applied at all times to the search results page? If so, you wil need to use this filter:

    https://searchandfilter.com/documentation/action-filter-reference/#edit-query-arguments

    and add an orderby condition. The code goes in to the child theme functions.php file.

Viewing 2 posts - 1 through 2 (of 2 total)