Home arrow PHP arrow Customizing WordPress Search Results to Sort by Title

Customizing WordPress Search Results to Sort by Title

Sorting search results by post title in WordPress is often useful, if your website needs its entries to be sorted alphabetically. As a quick background, WordPress is the most popular open source, free blogging/CMS platform. However, the default search results are sorted by date, so there is no easy way to sort them alphabetically except to edit the core WordPress search functionally source code.

TABLE OF CONTENTS:
  1. Customizing WordPress Search Results to Sort by Title
  2. The WordPress Search Results Function
  3. Use WordPress Query.php for customized search results
  4. Sort Search Results by Title Plug-in
  5. Designing a Complex Application
By: Codex-M
Rating: starstarstarstarstar / 5
May 05, 2009

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

There are a number of applications for which it would be useful to sort post titles alphabetically. For example, say you use WordPress for a social networking site. With that kind of site, people stop by and register their names. As a result, users need to be able to search for names in the WordPress search box. So the search results need to be sorted alphabetically so that visitors can easily find people's names.

There are countless applications for the ability to sort post titles alphabetically in WordPress. Here's another example: say you use WordPress on an online bookstore. Again, you'll need to alphabetize search results, by book titles and/or author names. As of February 2009, surprisingly enough, no WordPress plug-in has been developed to provide this feature.

In fact, one of the best ways to apply this feature is to work with the “Search Everything” plug-in. You can read more about this in: http://wordpress.org/extend/plugins/search-everything/ . A detailed discussion of this plug-in is beyond the scope of this article; however, sample applications are illustrated in the last section of this tutorial.

It is the objective of this article to explain how to sort WordPress search results by post title.

Basic Requirements and Enabling WordPress Search Widget

This tutorial has been tested to work in WordPress version 2.5.1 to 2.6.1. To tweak the WordPress search function appropriately, you need to have the following:  

  • Full FTP access to your WordPress site.
  • A newer version of WordPress, specifically 2.5.1 to 2.7 (older versions of WordPress have not been tested for this application, and it is recommended that you upgrade for security reasons).

The tweak will not work if you do not have full FTP access and the appropriate version of WordPress. You may need to coordinate with your web agency or any person that has full access to the website server files.

If you have all of the requirements, the next thing you need to do is enable the WordPress Search Widget. The steps below have been tested to work in WordPress version 2.5.1 to 2.6.1.

1. Go to Dashboard

2. Go to Design

3. In the list of sub-menus, namely Themes, Widgets and Theme Editor, click “Widgets”

4. In the first column, you will see “Available Widgets.” Find “Search” and then click “Add.” This will add a search form to your website.

After completing these steps, the search widget will now be shown in the “current widgets” column. Check the screen shot below for an example:



 
 
>>> More PHP Articles          >>> More By Codex-M
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: