Support » Plugin: Google XML Sitemaps » WPML compatibility

  • This is David from the WPML compatibility team.
    We had a few reports about WPML not working well together with Google XML Sitemaps and tried to find a workaround for our common users.

    The main problem is that Google XML Sitemaps uses custom DB queries and WPML doesn’t hook on custom queries to modify them.

    I wrote this little snippet and so far it has been working for our users:

    if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
        add_filter( 'option_sm_options', 'sm_wpml_exclude' );
    function sm_wpml_exclude( $value ) {
        global $wpdb;
        $ids = $wpdb->get_col( $wpdb->prepare(
            "SELECT element_id FROM {$wpdb->prefix}icl_translations"
            . " WHERE element_type LIKE 'post_%%' AND language_code <> '%s'",
        ) );
        $value['sm_b_exclude'] = $ids;
        return $value;

    I’m writing to find out if you are willing to include these lines in your plugin.
    If you will, we can add your plugin to our list of compatible plugins:

    Let me know what you think.

Viewing 3 replies - 1 through 3 (of 3 total)
  • maxgx


    hey David,
    i just tried your code in my functions.php (as also suggested by your support staff), re-saved options in Google XML Sitemap settings page and got the following error message:

    Error while saving options
    Pages saved

    checking the sitemap.xml file shows nothing has changed, i don’t see anything related to WPML’s translated content.

    if i comment out/remove your code from functions.php, the plugin message on saving the options goes back to:

    Configuration updated
    Pages saved

    WP version 4.8
    WPML version 3.6.3
    Google XML Sitemap version 4.0.8

    This is probably because you already have a value in ‘sm_b_exclude’.

    I have rewritten the fix slightly so this doesn’t happen and it will be included in next release of WPML which is currently going through QA.

    As soon as WPML 3.8 is released, this workaround can be removed.



    true, i’m excluding the Uncategorized category.
    didn’t realise the snippet was dealing with that option.
    thanks, looking forward to the release

    • This reply was modified 2 years ago by  maxgx.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WPML compatibility’ is closed to new replies.