WordPress.org

Ready to get started?Download WordPress

Forums

Qtranslate Slug
Hreflang creates broken link 404 (13 posts)

  1. Elnino3838
    Member
    Posted 8 months ago #

    Hi Carlos,

    I'm currently chasing my 404 errors.
    The line
    <link hreflang="fr" href="http://www.the3marketers.com/blog/fr/category/social-media/" rel="alternate" />

    in my header gives a broken link because it should be:

    <link hreflang="fr" href="http://www.the3marketers.com/blog/fr/category/media-sociaux/" rel="alternate" />

    media-sociaux is indeed the FR slug entered for this category in WP admin.

    I've looked at this thread but it's not working, probably because I am running a newer version of qTranslate and slug:

    http://wordpress.org/support/topic/plugin-qtranslate-slug-equivalent-of-qtrans_converturl?replies=11

    Thanks for your help.

    http://wordpress.org/plugins/qtranslate-slug/

  2. Jonathan Perret
    Member
    Posted 7 months ago #

    I'm having a similar problem! I am in the process of creating a new site (WordPress 3.7.1 with Zeefocus theme)in 4 languages. I have several pages set up, and qtranslate plugin installed, as well as qtranslate Slug. The 4 flags appear correctly at the top right of the site, and if I click on any one of them from the home page, all works fine. In other words, it switches from localhosy/mysite/en to localhost/mysite/es to localhost/myslte/fr, etc...In each case the navmenu is correctly translated, and if I navigate to any of the pages, they appear in the correct language, and the URL is also correct. For example, if I am in the Spanish option, I will get localhost/mysite/es/contacto or localhost/mysite/es/montaje, etc...However, if I try and navigate from any of these pages to the same in one of the other languages, I get a 404. In other words, if I am in localhost/mysite/es/contacto and I click on the French flag, the URL that appears is localhost/mysite/fr/contacto, which of course doesn't exist since that language's url is localhost/mysite/fr/contactez-nous.
    What is happening is that every time one exits a page in a certain language, it seems to keep that last language in the url (also seen on the href links for each flag).
    Does anyone have any clue about how to solve this??
    Thanks a lot for any help.
    Jonathan

  3. Jonathan Perret
    Member
    Posted 7 months ago #

    Perdona Carlos,
    No se si preferirías lo mencionado arriba, en Castellano??
    Gracias y un saludo,
    Jonathan

  4. Jonathan Perret
    Member
    Posted 7 months ago #

    Carlos, ya está solucionado!
    My fault......
    I had the original qtranslate code in the header.php file, such as this:

    <div class="chooselang" style="float:right;">
    <?php echo qtrans_generateLanguageSelectCode('image'); ?>
    </div>

    and I needed to put your qtranslate Slug code instead, as here:

    <div class="chooselang" style="float:right;">
    <?php if (function_exists('qts_language_menu')) qts_language_menu('image'); ?>
    </div>

    So now it's working great!
    Excellent plugin. Gracias.
    Jonathan

  5. Pedro Carvalho
    Member
    Plugin Author

    Posted 5 months ago #

    Elnino, do you still need help with your issue?

  6. Elnino3838
    Member
    Posted 5 months ago #

    Hi Carlos,

    Yes the problem still persists.
    If you check the URL http://www.the3marketers.com/blog/category/social-media/ you still have the code
    <link hreflang="fr" href="http://www.the3marketers.com/blog/fr/category/social-media/" rel="alternate" /> in the header which gives a 404.

    Jonathan's solution does not apply to me as I don't see anywhere in my template the line <?php echo qtrans_generateLanguageSelectCode('image'); ?>

    Thanks for your help!

  7. Pedro Carvalho
    Member
    Plugin Author

    Posted 5 months ago #

    hi @elnino3838,

    try to follow the instructions from my other post that you linked at the beginning:

    in qtranslate_hooks.php,
    Line 44:

    echo '<link hreflang="'.$language.'" href="'.qtrans_convertURL('',$language).'" rel="alternate" />'."\n";

    and replace it with

    global $qtranslate_slug;
    $language_url = $qtranslate_slug->get_current_url($language);
    echo '<link hreflang="'.$language.'" href="'.$language_url.'" rel="alternate" />'."\n";

    don't forget that if update qtranslate this changes will be lost

  8. Elnino3838
    Member
    Posted 5 months ago #

    Hi Carlos,

    I've replaced the line. Now I got a fatal error:

    Fatal error: Call to a member function get_current_url() on a non-object in /xxx/wp-content/plugins/qtranslate/qtranslate_hooks.php on line 44

    Running Version 2.5.34.
    I've seen this issue addressed in another post but I didn't understand your explanation:

    http://wordpress.org/support/topic/plugin-qtranslate-slug-equivalent-of-qtrans_converturl?replies=11

  9. Carlos
    Member
    Plugin Author

    Posted 2 months ago #

  10. Elnino3838
    Member
    Posted 2 months ago #

    I've tried updating to qtranslate-slug 1.1.7 - the same link still shows up in the source code.
    I've tried installing mqtranslate but I can't activate the plugin:

    Plugin could not be activated because it triggered a fatal error.

    Fatal error: Cannot redeclare qtrans_initJS() (previously declared in /xxx/wp-content/plugins/qtranslate/qtranslate_javascript.php:22) in /xxx/blog/wp-content/plugins/mqtranslate/mqtranslate_javascript.php on line 433

  11. Pedro Carvalho
    Member
    Plugin Author

    Posted 2 months ago #

    hi @elnino,

    you need to use one or the other. disable qtranslate if you want to use mqtranslate.

  12. Elnino3838
    Member
    Posted 2 months ago #

    Nope sorry not working. When using mqtranslate, some links are broken, switching to the alternative language doesn't work any more ... Too many issues and I don't have time to look through all of them to test if this plugin is going to resolve the prob.
    I'll stay with qtranslate and this buggy 404 link in the header.

  13. Pedro Carvalho
    Member
    Plugin Author

    Posted 2 months ago #

    well, i just tried the hack i posted earlier but this time on mqtranslate file. it now shows the right hreflang link.

    i'll try to come up with a solution using only this plugin.

    thanks for reporting @elnino.

    foreach($q_config['enabled_languages'] as $language) {
      if($language != qtrans_getLanguage()) {
        global $qtranslate_slug;
        $language_url = $qtranslate_slug->get_current_url($language);
        echo '<link hreflang="'.$language.'" href="'.$language_url.'" rel="alternate" />'."\n";
      }
    }

Reply

You must log in to post.

About this Plugin

About this Topic