• ResolvedPlugin Author Pedro Carvalho

    (@pedroghandi)


    Hi Carlos, first, let me thank you for this awesome plugin.

    so, let me expose the problem:

    qtranslate prints out this line in header. ( in qtranslate_hooks.php)

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

    so, for every page, cat or post, google reports a 404 link for every language in my site.

    is there a equivalent for qtrans_convertURL() ?

    thanks a lot!

    https://www.ads-software.com/extend/plugins/qtranslate-slug/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Carlos

    (@carlos_a_sanz)

    Hello,

    i omitted this function because it makes no sense, you can use wordpress official functions for current language (get_permalink, get_term_link, etc.. )

    Anyway there is a function to know the current url in other language:

    global $qtranslate_slug;
    $english_url = $qtranslate_slug->get_current_url('en');

    In next versions i will add another function to know other urls in no current language.

    Hope this helped you.
    C.

    Plugin Author Pedro Carvalho

    (@pedroghandi)

    thanks Carlos for the quick reply.

    that function was a nice little wrapper that all kinds of taxonomies and post types.

    gonna try your suggestion and be right back to post the results.

    Plugin Author Pedro Carvalho

    (@pedroghandi)

    works perfectly!

    here’s my code to replace that line (around line 489)

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

    hi pedroghandi,

    unfortunately i get the same 404 when switching from one language back to the other. I’m very interested in your solution but I can’t reproduce it.

    Could you tell me in which line I would have to put / replace the code you posted above? That’d be awesome.

    Thanks a lot
    matteo

    Plugin Author Pedro Carvalho

    (@pedroghandi)

    Hi matteo

    in qtranslate_hooks.php, around line 489

    look for this line:

    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";

    thanks for the quick response

    now i get one of my favorites ??
    Fatal error: Call to a member function get_current_url() on a non-object in /usr/www/users/hoteltq/wp-content/plugins/qtranslate/qtranslate_hooks.php on line 44

    i found the code around line 44 (qtranslate_hooks.php has about 360 lines in the latest version 2.5.28) where i replaced it with your snippet. Maybe I need another version of qtranslate – could this do the trick?

    sincerely
    matteo

    Plugin Author Pedro Carvalho

    (@pedroghandi)

    i’m using 2.5.30 but nevertheless, you’re right. its around 44 indeed.

    hm does it look like this:

    // set links to translations of current page
    	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";
              }
    	}

    notice the global $qtranslate_slug; part.

    I would just like to point to the fact, that a simple language switcher based on a current URL query is not applicable in every situation.

    Right now I’m developing a multi-language website that’s integrated with Facebook. See where I’m going with this?
    I’m in need of a function that would let me output a permalink to only the base language version of a post, for use in the loop (ie. front page recent posts list), so the Facebook likes and comments don’t get separated between different language permalinks.

    Any edits you’d suggest?

    Also, the get_current_url solution doesn’t account for any tickets added by external referrals. So again, in this situation, all the Facebook plugins point to yet another location.

    Thanks Carlos,
    Its working, but is there any way to get different urls depending upon the language?

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Plugin: Qtranslate Slug] equivalent of qtrans_convertURL()’ is closed to new replies.