Support » Plugin: XML Sitemap & Google News » Multilingual website with qTranslate X

  • Resolved ai1dro0knotbot

    (@ai1dro0knotbot)


    Hi,

    I’m using your astonishing plugin, but I was lacking capacity to complain google rel=”alternate” demands.

    So I added this portion of code to feed-sitemap-post_type.php

    ~ line 22
    $enabled_languages = get_option('qtranslate_enabled_languages');        // AG: 
    ...
    ~ line 54-66
    	$thisUrl = esc_url( get_permalink() );                            // AG: 
    	?>
    	<url>
    		<loc><?php echo $thisUrl;                                     // AG: 
    		?></loc>
    <?php 
        for ($lngCnt=1; $lngCnt<count($enabled_languages); $lngCnt++) {   // AG: 
            
    ?>
    			<xhtml:link rel="alternative"  hreflang="<?php echo $enabled_languages[$lngCnt]; ?>" href="<?php echo qtranxf_convertURL($thisUrl, $enabled_languages[$lngCnt]); ?>"/>
    <?php 
        }                                                                 // AG: 
    ?>
    

    Now it generates alternate links as google wants to see.
    Reference manual here.

    I’m not too deep into MVC programming, so I did temporary workaround. It would be pleasure if you could add such ability to whole plugin in your professional way.

    Thank you in advance.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author RavanH

    (@ravanh)

    Hi, thanks for sharing that 🙂

    Question: does qTranslate X not add tags like <link rel="alternate" hreflang="lang_code" href="url_of_page" /> in the page headers? If so, adding rel:alternative tags in the sitemap should not really be needed. Or did you experience otherwise?

    qTranslate X added the following:

    <link hreflang="es" href="https://www.test.net/es/" rel="alternate" />
    <link hreflang="x-default" href="https://www.test.net/" rel="alternate" />

    With it’s language switching menu.

    I want my sitemap to match search engine requirements. As far as I see, google pretty strictly enforces own guidelines.

    Today google noticed, that directive
    xmlns:xhtml="http://www.w3.org/1999/xhtml"
    Should be added also.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Multilingual website with qTranslate X’ is closed to new replies.