Site icon Hip-Hop Website Design and Development

change posts_orderby of the callback wp_query?

I discovered this reply that helps with ordering question outcomes by the submit kind in my search question. However the concern is that it helps after I go to

https://instance.com/?s=questionpercent20string

that’s if I search utilizing native php search. And that is nice. However I even have the search through ajax – after I kind, the ajax will name my callback operate that’s registered on a customized relaxation endpoint.

So I’m questioning if there’s any manner that I can establish that customized question in order that I can reuse that filter? Within the conditional:

if ( ! is_admin() && is_search() && is_my_custom_search_query() ) { 

The choice is to attempt to rewrite the CASE orderby to WP_Query which I’m not positive is feasible tbh.

Search question for ajax seems to be like:

  $query_string   = sanitize_text_field( wp_unslash( $_GET['searchString'] ) );
  $page_no        = intval( $_GET['pageNo'] );
  $posts_per_page = 9;
  $offset         = ( $page_no - 1 ) * $posts_per_page;

  $search_args = array(
      'posts_per_page' => $posts_per_page,
      'post_status'    => 'publish',
      'perm'           => 'readable',
      's'              => $query_string,
      'offset'         => $offset,
  );

  $search_results = new WP_Query( $search_args );