HomePHP Page 5 - Customizing WordPress Search Results to Sort by Title
Designing a Complex Application - PHP
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.
As said earlier, this functionality can be used to create complex applications in WordPress. For example, say you need to create a music site that will enable users to rate a song from 1 to 5. There are also other users that might be looking for great songs in your catalog.
The following are example title tags (dynamically generated as the average song rating) of the song post. Assume all of them use “rock-music” as the custom fields in the post (combine with http://wordpress.org/extend/plugins/search-everything/ , so that WordPress will look at custom field data as a basis for the search).
Song rating 4.5 “ Song title 1”
Song rating 3.2 “ Song title 2”
Song rating 4.9 “Song title 3”
If a user types into the search box the phrase “rock music,” WordPress will then return the search results in the descending order of song ratings, so that listeners will be able to listen the best songs first: