Order Search Results Posts

You are here:
Print

You can order posts displayed on the search results page in the Ascending or Descending order of its various attributes as listed below.

none –        No order (available since WP 2.8).
ID –             Order by post id.
author –     Order by author.
title –          Order by title.
name –       Order by post name (post slug).
type –         Order by post type (available since WP 4.0).
date –         Order by date.
modified – Order by last modified date.
parent –     Order by post/page parent id.
rand –        Random order.
comment_count – Order by number of comments (available since WP 2.9).
relevance – Order by search terms in the following order: First, whether the entire sentence is matched. Second, if all the search terms are within the titles. Third, if any of the search terms appear in the titles. And, fourth, if the full sentence appears in the contents.
menu_order – Order by Page Order. Used most often for Pages (Order field in the Edit Page Attributes box) and for Attachments (the integer fields in the Insert / Upload Media Gallery dialog), but could be used for any post type with distinct ‘menu_order’ values (they all default to 0).
meta_value – Note that a ‘meta_key=keyname’ must also be present in the query. Note also that the sorting will be alphabetical which is fine for strings (i.e. words), but can be unexpected for numbers (e.g. 1, 3, 34, 4, 56, 6, etc, rather than 1, 3, 4, 6, 34, 56 as you might naturally expect).

You can configure Order By option of search form to control order of search results posts. To configure Order By option just edit the search form and go to its Options section then select the desired Order By option values and save the changes.