Change the JSON+LD search URL

Last update: 22 June, 2016

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. That's as simple as doing this:

  * Changes the search slug to /search/ for the JSON+LD output
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' );

Was this article helpful? ·