Migration guide · WordPress

Keep WordPress search plugins working after the Custom Search shutdown

Some WordPress plugins replace your site's search with results from Google's Custom Search JSON API, using an API key and an engine ID. Google discontinues that API on January 1, 2027. A ten-line must-use plugin sends those requests to Searlo's drop-in instead and keeps results on your own site, without editing the search plugin.

Which plugins this covers

Plugins that call https://www.googleapis.com/customsearch/v1 (or /siterestrict) from PHP through the WordPress HTTP API, that is wp_remote_get() and friends. Search with Google by rtCamp is one: it asks for an API Key and an Engine ID under Settings, Reading, and writes Google's URL into its code with no setting to change it.

Plugins that embed Google's search box with its script (the Programmable Search Element) do not use the JSON API, and this does not apply to them. Neither does a plugin that bundles its own HTTP client; search its code for customsearch to see which kind you have.

The must-use plugin

It runs before WordPress sends any HTTP request. Requests for Google's Custom Search URL go to Searlo with the same path and parameters, plus siteSearch set to your site's host, because Searlo ignores cx and would otherwise search the whole web. Every other request is untouched.

wp-content/mu-plugins/searlo-custom-search.php

<?php
/**
 * Plugin Name: Searlo for Custom Search JSON API
 * Description: Sends WordPress requests for Google's Custom Search JSON API to Searlo's drop-in endpoint.
 */

add_filter(
	'pre_http_request',
	function ( $response, $args, $url ) {
		$google = 'https://www.googleapis.com/customsearch/v1';
		if ( 0 !== strpos( $url, $google ) ) {
			return $response;
		}
		// Searlo ignores cx and searches the whole web, so restrict results to this site.
		$url = add_query_arg( 'siteSearch', wp_parse_url( home_url(), PHP_URL_HOST ), $url );
		return wp_remote_request( 'https://api.searlo.tech/customsearch/v1' . substr( $url, strlen( $google ) ), $args );
	},
	10,
	3
);

Install it in three steps

  1. 01Save the fileCreate wp-content/mu-plugins if it does not exist and save the code above as wp-content/mu-plugins/searlo-custom-search.php. Must-use plugins load automatically; there is nothing to activate.
  2. 02Put your Searlo key in the search pluginIn Search with Google, that is Settings, Reading, Search with Google Settings: API Key becomes your Searlo API key. Leave Engine ID as it is, and either Search Type works.
  3. 03Search your siteRun a search on the front end. Results now come from Searlo, limited to your domain, and each search shows in your Searlo dashboard.

Notes

Each search is one call, 1 credit, and a search that returns an error is not charged. Search with Google keeps each result page in a transient for a day, so a repeated search does not call again until it expires, and pages it cached from Google before the switch stay until then too.

siteSearch is your home URL's host. If your site search should cover another domain, change the add_query_arg line, or remove it to search the whole web.

Google's Site Restricted JSON API, which Search with Google uses unless you choose the other search type, stopped serving traffic on January 8, 2025. With this plugin both search types work again, because Searlo answers both paths.

We ran this on 2026-10-25 with WordPress 7.1.3 and Search with Google 1.2.3, for both search types and for a front-end search.

FAQ

Questions

Do I have to edit the search plugin?

No. The must-use plugin intercepts the request through WordPress's pre_http_request filter, so the search plugin can update normally.

Will results include other websites?

No. The must-use plugin adds siteSearch with your site's host to every request, which Searlo applies as a site: restriction.

Does it work with other Custom Search plugins?

With any plugin that requests https://www.googleapis.com/customsearch/v1 through the WordPress HTTP API and reads the standard response fields. We tested Search with Google; for another plugin, run one search and check it in your Searlo dashboard.

Keep your site search working

Create a key, save one file, paste the key into your search plugin.