Change the JSON+LD search URL

Yoast SEO outputs code to make search in sitelinks work better for your site, read more about that feature here.

If your WordPress install doesn't use the default{keyword} type search URLs but for instance uses{keyword}, you'll want to change the output of the JSON+LD code that Yoast SEO puts out.

We highly recommend taking a backup of your site before you edit theme files.

To change the URL that Yoast outputs as part of the JSON+LD Code:

/* Change the search slug to /search/
 * for the JSON+LD output in Yoast SEO
function yst_change_json_ld_search_url() {
return trailingslashit( home_url() ) . 'search/{search_term}';
add_filter( 'wpseo_json_ld_search_url', 'yst_change_json_ld_search_url' );

Disable/Remove the JSON+LD Schema

You can disable the JSON+LD output completely by adding the code below to the functions.php file of your theme.

add_filter('wpseo_json_ld_output', '__return_false');

More JSON+LD Filters

We have a few more filters listed here that are related to JSON+LD.

Was this article helpful? ·