Skip to content

Instantly share code, notes, and snippets.

@timstl
Last active February 24, 2025 07:49
Show Gist options
  • Select an option

  • Save timstl/5348604 to your computer and use it in GitHub Desktop.

Select an option

Save timstl/5348604 to your computer and use it in GitHub Desktop.
Remove "Home" link from Yoast WordPress SEO's breadcrumbs. Add to functions.php.
function tg_remove_home_breadcrumb($links)
{
if ($links[0]['url'] == get_home_url()) { array_shift($links); }
return $links;
}
add_filter('wpseo_breadcrumb_links', 'tg_remove_home_breadcrumb');
@jg314
Copy link
Copy Markdown

jg314 commented Feb 14, 2014

Thanks for providing this. Currently it won't work because the filter calls a function that doesn't exist. If you change the title of the function from "wpseo_remove_home_breadcrumb" to "tg_remove_home_breadcrumb" it will work perfectly.

@unclego
Copy link
Copy Markdown

unclego commented Oct 5, 2016

Dont't work without this safety check with trailingslashit

if ( trailingslashit($links[0]['url']) == trailingslashit(get_home_url()) )

@marcbacon
Copy link
Copy Markdown

If anyone else needs this here is a slightly updated version:

function wpseo_remove_home_breadcrumb($links) { if ( $links[0]['url'] == home_url('/') ) { array_shift($links); } return $links; } add_filter('wpseo_breadcrumb_links', 'wpseo_remove_home_breadcrumb');

@OksanaRomaniv
Copy link
Copy Markdown

If anyone else needs this here is a slightly updated version:

function wpseo_remove_home_breadcrumb($links) { if ( $links[0]['url'] == home_url('/') ) { array_shift($links); } return $links; } add_filter('wpseo_breadcrumb_links', 'wpseo_remove_home_breadcrumb');

Thanks, @mbacon40, worked perfectly!

@fatihturan
Copy link
Copy Markdown

Is there any way to change home url to another url instead of removing home link?

@timstl
Copy link
Copy Markdown
Author

timstl commented Aug 17, 2021

Is there any way to change home url to another url instead of removing home link?

It's been a while since I have used this, but I think instead of using array_shift you could do something like this:

if ($links[0]['url'] == get_home_url()) { $links[0]['url'] = 'https://someurlhere.com'; }

You would probably want to use get_permalink() or site_url() to generate the desired URL - not hardcode it - but I think that idea would work.

@VaniaRensi
Copy link
Copy Markdown

VaniaRensi commented Aug 8, 2024

This is not working now, maybe they changed something. Any Idea on how to change the link? I'm on the blog, I don't need the Home, I want the forst link to be the Posts Archive page.

@zachakbar
Copy link
Copy Markdown

zachakbar commented Feb 18, 2025

This worked for me.

 * Hide home link for breadcrumbs
 */
function remove_home_breadcrumb($links) {
	if (isset($links[0]) && strpos($links[0]['url'], get_home_url()) !== false) {
		unset($links[0]);
	}
	return $links;
}
add_filter('wpseo_breadcrumb_links', 'remove_home_breadcrumb');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment