search ]

Remove Canonical URL from Search Results

If you want to remove canonical URLs from search results in WordPress, and you use WordPress SEO by Yoast, add the following filter to your child theme’s functions.php file:

function yoast_remove_canonical_search( $canonical ) {
	if( is_search() ) {
		return false;
	} else {
		return $canonical;
	}
}
add_filter('wpseo_canonical', 'yoast_remove_canonical_search');

More on what a canonical tag is and how to use it in the post What is a Canonical Tag and how to use it?

Join the Discussion
0 Comments  ]

Leave a Comment

To add code, use the buttons below. For instance, click the PHP button to insert PHP code within the shortcode. If you notice any typos, please let us know!

Savvy WordPress Development official logo