WordPress.org

Forums

WP No Category Base
[resolved] compatibility with qTranslate plugin (3 posts)

  1. Daniele Raimondi
    Member
    Posted 5 years ago #

    THE PROBLEM:
    I am using the language plugin qtranslate to create a bilingual site, italian as default language and english as second language. I've setted qTranslate to add a locale abbreviation to urls for the second (and eventually all other) language(s):

    http://domain.com/nameofcat for default lang (italian)
    http://domain.com/en/nameofcat for english

    As i've installed and enabled the WP No Category Base Plugin, the locale abbreviation has been removed from every url, and now WP shows every page in the default language and I have to switch to english every time.

    THE SOLUTION:
    Creanodesign, on the qTranslate forum, has found the solution to the incompatibility between “WP No Category Base” and “qTranslate”.
    You can read about it there:

    http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=3&t=993&p=5893#p5893

    just find the 2 occurences of this line in no-category-base.php:

    $catlink = trailingslashit(get_option( 'home' )) . user_trailingslashit( $category_nicename, 'category' );

    and change them to

    if (function_exists('qtrans_convertURL'))
    		$catlink = trailingslashit(qtrans_convertURL(get_option( 'home' ))) . user_trailingslashit( $category_nicename, 'category' );
    	else
    		$catlink = trailingslashit(get_option( 'home' )) . user_trailingslashit( $category_nicename, 'category' );

    Hope it can be useful

    http://wordpress.org/extend/plugins/wp-no-category-base/

  2. erichazann
    Member
    Posted 5 years ago #

    I only found one instance of the code you mention. The "second" instance of setting catlink is

    $catlink = trailingslashit(get_option( 'home' )) . user_trailingslashit( $query_vars['category_redirect'], 'category' );

    If you replace that with your code, you will break your redirects on old category URLs. You have to edit the code to swap out $category_nicename for $query_vars['category_redirect']

  3. Daniele Raimondi
    Member
    Posted 5 years ago #

    yes you are right. But (luckily) I putted this error in this topic only and not in the code I patched on my WP installation :D
    So, for the sake of clarity, here are the right version:

    1st istance:
    FROM

    $catlink = trailingslashit(get_option( 'home' )) . user_trailingslashit( $category_nicename, 'category' );

    TO

    if (function_exists('qtrans_convertURL'))
    		$catlink = trailingslashit(qtrans_convertURL(get_option( 'home' ))) . user_trailingslashit( $category_nicename, 'category' );
    	else
    		$catlink = trailingslashit(get_option( 'home' )) . user_trailingslashit( $category_nicename, 'category' );

    2nd istance:
    FROM

    $catlink = trailingslashit(get_option( 'home' )) . user_trailingslashit( $query_vars['category_redirect'], 'category' );

    TO

    if (function_exists('qtrans_convertURL'))
    			$catlink = trailingslashit(qtrans_convertURL(get_option( 'home' ))) . user_trailingslashit( $query_vars['category_redirect'], 'category' );
    		else
    			$catlink = trailingslashit(get_option( 'home' )) . user_trailingslashit( $query_vars['category_redirect'], 'category' );

    Thanks to erichazann for pointing this out.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP No Category Base
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic