SearchWP Documentation

View the installation guide, browse the Knowledge Base, find out about SearchWP’s many hooks

Creating Your SearchWP Customizations Plugin

Using the available hooks you can customize the behavior of SearchWP in many ways.

What are hooks?

‘Hooks’ are functions that integrate with WordPress/SearchWP behavior without needing to edit core files. There are two types of hooks:

Actions: Actions are arbitrary points in the execution of the core code that allow you to fire your own functions before the core code continues

Filters: Filters send a variable (or multiple variables) out of the core code, allow you to filter/change it, and send it back to the core code.

SearchWP uses both Actions and Filters throughout its code base.

How to add your own hooks

The recommended way to add your own custom hooks is by making use of a custom Plugin that you write and maintain yourself.

This is the recommended method because it will encapsulate all of your SearchWP customizations in a way that is not directly attached to the active theme. You’ll be able to continue using your customizations should you change themes because all of your hooks will be contained in a single, standalone Plugin.

To create your own SearchWP Customizations Plugin:

Begin by creating a file named searchwp-customizations.php in your plugins folder (which is ~/wp-content/plugins by default)

Paste the following into the newly created, empty file:

<?php
/*
Plugin Name: SearchWP Customizations
Description: Customizations for SearchWP
Version: 1.0.0
*/
// Add all hooks and custom code here.

Once that file is saved, navigate to the Plugins page of your WordPress installation.

You’ll see a new Plugin available named SearchWP Customizations. You can then activate that plugin and all of your hooks will be put in place.

A Better WordPress Search Experience

Get the best WordPress search plugin. Trusted by 50,000+ websites.

Get SearchWP Now
Multiple Search Engines Icon