Home arrow PHP arrow 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.

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

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:

Song rating 4.9 “Song title 3”

Song rating 4.5 “ Song title 1”

Song rating 3.2 “ Song title 2”



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

blog comments powered by Disqus
   

PHP ARTICLES

- 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...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 8 - Follow our Sitemap

Dev Shed Tutorial Topics: