How to Fix WordPress Transposh YOAST Sitemap Problem

Transposh is an excellent free translation plugin for WordPress. Also YOAST SEO is an excellent SEO plugin for WordPress. But there is an incompatibility problem with each other when YOAST sitemap files produced.

The problem is YOAST doesn’t see the pages produced by Transposh and doesn’t add them to sitemap_index.xml. As a result, no search engine see your translated pages. This can be fixed by adding your translated pages to search engines one by one (eg. by Google Search Console) but this is not a practical solution. This was exactly what I was living at IZREVIEW

Thanks to Vidyut Gore. She has prepared a fix for the problem in 2018 but since then both Transposh and YOAST SEO plugins released many new versions and Vidyut’s solution is not working now.

When I realized that, I started to update the “patch” and I released a Transposh-Yoast sitemap problem solution. As a date of 19.4.2020, version of Yoast SEO is v13.5 and Transposh is v1.0.6.1 and this patch is working fine. But if Yoast or Transposh release a new version, that might change. Here is the Transposh – Yoast sitemap incompatibility problem solution as of 19.4.2020:

How to Solve Yoast – Transposh Sitemap Problem

Time needed:Ā 10 minutes.

How to Solve Yoast – Transposh Sitemap Problem

  1. Connect your webserver via cPanel

    If you are using other than cPanel to manage your web server, use it.

  2. Open File Explorer at cPanel

    Navigate to \your_site_name.com\wp-content\plugins\wordpress-seo\inc\sitemaps

  3. Edit class-post-type-sitemap-provider.php File

    (It is a good idea to backup that file before)

  4. Find section for patch area

    /**
    * Filter URL entry before it gets added to the sitemap.
    *
    * @param array $url Array of URL parts.
    * @param string $type URL type.
    * @param object $post Data object for the URL. */
    $url = apply_filters( 'wpseo_sitemap_entry', $url, 'post', $post );
    if ( ! empty( $url ) ) {
    $links[] = $url;
    }
    }
    unset( $post, $url );
    }

  5. Add Transposh Info

    Change this section to:
    /**
    * Filter URL entry before it gets added to the sitemap.
    *
    * @param array $url Array of URL parts.
    * @param string $type URL type.
    * @param object $post Data object for the URL. */
    $url = apply_filters( 'wpseo_sitemap_entry', $url, 'post', $post );
    if ( ! empty( $url ) ) {
    $links[] = $url;
    }
    /** Transposh Fix */
    $langurls = apply_filters( ‘wpseo_sitemap_language’,$url);
    if ( is_array( $langurls )) {
    foreach ($langurls as $langurl) {
    $links[] = $langurl;
    continue;
    }
    }
    /* End Transposh fix */


    }
    unset( $post, $url );
    }

  6. Save class-post-type-sitemap-provider.php File

  7. Test your sitemap file.

    Patch is finished. Now open a browser and check your sitemap file by going to
    https://www.your_site_name.com/sitemap_index.xml

If you have any problem or comment, feel free to leave a comment below.

Update: As of 28.4.2020, Yoast SEO released v14.0, and previous patch is overwritten by YOAST. For this reason, you need to do above procedure again.

2 thoughts on “How to Fix WordPress Transposh YOAST Sitemap Problem”

  1. Thanks. I’ll update my post as well, so that those who were using the earlier fix may find the new one. I stopped updating the site I was using Transposh on, so neglected to update the fix. Much appreciated.

Leave a Reply

Your email address will not be published. Required fields are marked *