Support » Plugin: Yoast SEO » When site url is changed and Yoast breadcrumbs are wrong

    I am developing on local, and another plugin I am required to use for the project forced me to rename my local development url so that the license would see it as a development version of the licensed site, rather than another site/separate install. When I changed all the settings in my local config files and renamed it in MAMP, everything seemed fine until I tried to use my Yoast generated breadcrumbs. They were for the old url pattern still. I dug around for awhile trying to get things to re-index, but I couldn’t get any luck.

    I found the wp_yost_* tables in the database and realized that you are indexing the whole URL in the permalink field on a post. You are not pulling the current site_url() from WP.

    It took several hours to figure out, but I had to delete the Yoast SEO plugin, drop every table and delete every row with “wp-seo” and “yoast” in it, then re-install the plugin to get a fresh install, and subsequently a fresh post url permalink index triggered.

    A site url change should be detected and then re-indexing should be triggered, OR the permalink indexing should be path only and should be dynamically generated by combing site_url() and permalink-path

Viewing 8 replies - 1 through 8 (of 8 total)
  • This still appears to be an issue



    Thread Starter shanemac10


    Thank you @andimorton, that works pretty well! ^

    I just ran into this same issue again when I had to spin up a fresh instance because of a root kit attack from a vulnerability in a plugin we were using. As we were getting the new instance prepared the migration tools changed links to the new instance’s IPv4 because we hadn’t re-setup the DNS yet… uhg, it never ends!

    Michael Albers


    I had the same issue, recently (

    After searching more, I stumbled upon this and got an idea.

    Luckily my blog doesn’t have many posts. I removed the URL slug on the posts with issues and saved the post. When the new URL slug was created, the issue was resolved.

    For larger blogs, maybe the plugin Rebuild Permalinks might be a solution. I haven’t tested it, though.

    Hit this problem we need to keep the old url running though but all front facing needs the new url (convoluted intranet deployment)

    Anyway I came up with this using Yoast’s published filters. Stick this in your theme’s functions.php file and it will compare the domain of each breadcrumb to that of your WP Site url and replace if needed.

    Its not been tested massively and isn’t super efficient but it seems to do the job.

     //yoast breadcrumbs replace with site url filter
    function filter_wpseo_breadcrumb_links( $this_crumbs ) { 
    		$liveURL = parse_url(get_option('siteurl'))['host'];		
    	    foreach($this_crumbs as $key => $crumb){
    	    	$url = parse_url($crumb['url']);
    		if($url['host'] && $url['host'] != $liveURL){
    		    $this_crumbs[$key]['url'] = str_replace($url['host'], $liveURL, $this_crumbs[$key]['url']);
        return $this_crumbs; 
    add_filter( 'wpseo_breadcrumb_links', 'filter_wpseo_breadcrumb_links', 10, 1 );

    apologies for the indenting this editor borks all my code

    • This reply was modified 1 year, 11 months ago by latro666. Reason: tried to get this to format the code better
    • This reply was modified 1 year, 11 months ago by latro666.

    I had the same issue on a large site.

    In my case, the first solution of this article helped to recreate the broken permalinks:

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘When site url is changed and Yoast breadcrumbs are wrong’ is closed to new replies.