Developers Quickstart – How to Extend Ajax Live Search

Want to extend ajax live search even further?

It’s actually easy to do. This tutorial walks you through the process of extending this WordPress plugin.

All you need is a little knowledge about how WordPress plugins work and how to use action and filter hooks. If you are totally new to this; I suggest that you checkout the WordPress codex first.

In this example; we are going to create a plugin that changes the number of results displayed on a search results page.

To accomplish this; we will attach a filter to the following hook: als_posts_per_page

On your desktop; create a new file and name it my-plugin.php, or anything that you want to use as the name of our new plugin.

Now open it using your favorite editor ( I use notepad++ ) and type the following piece of code.

If you have a basic idea of plugin development, then the following snippets should be very simple to follow up.

 * Plugin Name: My Plugin Name
 * Plugin URI:
 * Description: A basic description of my plugin.
 * Author: John Doe
 * Version: 1.0.0
 * Author URI:

In the same file, append the following:

function my_custom_result_text( $posts_per_page ){
	//This will force ajax live search to display 20 results per page
	return 20;
add_filter('als_posts_per_page', 'my_custom_posts_per_page');

That’s all. The plugin is complete. Do the following to install it :-

  1. Compress it into a zip file.
  2. Open your WordPress admin dashboard.
  3. Click on plugins > Add New > Upload.
  4. Upload the compressed file.
  5. Wait for WordPress to install it the click activate on the next screen.

Try searching for a phrase that you know will return lots of results. You should notice that the result page now contains 20 posts.

Extending a plugin can never get any easier.

Ajax live search bundles lots of other hooks that you can see below. They all work in the same way as the above example. Take a look at them…

This is a list of other filters that you can hook into in your custom plugin. The list is not complete and we will frequently update it so make sure you bookmark this post.

Name Since
als_posts_per_page 1.0.0
als_date_query 1.0.0
als_wp_query_post_types 1.0.0
als_tag_not_in 1.0.0
als_tag_in 1.0.0
als_tag 1.0.0
als_category_not_in 1.0.0
als_category_in 1.0.0
als_category_name 1.0.0
als_cat 1.0.0
als_author_name 1.0.0
als_author_not_in 1.0.0
als_author_in 1.0.0
als_search_results 1.0.0
als_query_modifiers 1.0.0
als_the_autoloader_image 1.0.0
als-ajax-search-fields 1.0.0
als_cat 1.0.0
als_category_name 1.0.0
als_category_in 1.0.0

As you can see;

Extending this plugin to improve WordPress search even further is simple and fast. In case you have any feature requests then don’t hesitate to send us a message.

Leave a Reply

Your email address will not be published. Required fields are marked *