Order of results in Ajax search

Ivory Search Forums Support Order of results in Ajax search

Viewing 1 reply thread

You must be logged in to create new topic or reply to the topic.

  • Author
    Posts
    • #12881
      dotboy
      Participant
      • Topics: 1
      • Replies: 0

      Hello, I’d like to order the ajax search results in the reverse order they seem to want to come in at. I have a list of people who all joined an organisation at different times, and the ajax search returns them oldest first. I have a custom meta field of enrolment_year which I’d love to use for sorting. Is this possible?

      Thanks, Peter

    • #12883
      Ivory Search
      Keymaster
      • Topics: 0
      • Replies: 1,735

      I hope you are well today and thank you for your question.

      You can order it by using the meta_value in the search form options as described below.

      Order Search Results Posts

      You also have to develop some custom code to add a meta key in the search query as below.

      function func_is_pre_get_posts( $query ){
            $query->set( 'meta_key', 'meta_key_name' );
      }
      add_action('is_pre_get_posts', 'func_is_pre_get_posts');

      Best regards,
      Ivory Search Support

Viewing 1 reply thread

You must be logged in to create new topic or reply to the topic.