Note: You are viewing the documentation for Version 4View Version 3 Docs


Since: 4.0.0

Table of Contents

Register an Extension to be used in SearchWP, specifically in the Extensions menu of the SearchWP settings UI.


Type Parameter Default Since
Array $extensions [] 4.0.0


All hooks should be added to your custom SearchWP Customizations Plugin.

Add custom Extension to settings UI

Starter class to implement a custom Extension that has a link in the Extensions dropdown of the SearchWP settings screen and an associated view when that link is clicked.

// Add custom SearchWP Extension to Extensions dropdown in settings UI.
// SearchWP Extensions must be a class that starts with "SearchWP"
// immediately followed by your unique class name.
class SearchWPMyExtension {
function __construct() {
add_filter( 'searchwp\extensions', function( $extensions ) {
// Following the class name rule, the array key is your unique
// class name _excluding_ the required "SearchWP" prefix.
$extensions['MyExtension'] = __FILE__;
return $extensions;
} );
// Render Extension view.
function view() {
<h3>My Extension</h3>
new MySearchWPExtension();

How to use this code

Fix keyword search on your site. No coding required!

Now you can utilize all of the content that's gone unrecognized by native WordPress keyword search instantly with SearchWP

Get SearchWP