0
votes

I use wordpress and I have the following question,

I use the URL: - www.mysite.com/page - www.mysite.com/cat/page - www.mysite.com/custompostype/post

The value of permalinks is %category%/%postname%, everything works fine except now I have to use two languages ​​and I want to configure as follows:

  • www.mysite.com/EN/page
  • www.mysite.com/ES/cat/page
  • www.mysite.com/BR/custompostype/post

I want to change the structure of wordpress urls where the first rule is the language and to take it as variable value. Similar to /%lang%/%category%/%postname%/

i used the wp_rewrite and have had no success, any idea?

1
This answer could help you - stackoverflow.com/questions/10304527/… - McNab
I use the plugins: Advanced custom fields, custom post types UI and CMS tree page view and when I activate the plugin you indicate me the following error: Fatal error: Call to undefined function qtrans_parseURL() in /var/www/faytur-redesing/www/wp-content/plugins/qtranslate-slug-with-widget/qtranslate-slug-with-widget.php on line 304 - Miguel Migeru
Ah well, thats why I added that as a comment rather than an answer. Why don't you look through the plugin code to see how it was being tackled? It might not work like magic straight out the box but it should point you in the right direction and help you augment the question to solicit an answer - McNab

1 Answers

0
votes

for now I just found a solution to my problem, which I handled sessions

  <?php function init_sessions() {
     if (!session_id()) {
         session_start();
     } } add_action('init', 'init_sessions'); ?> <?php function detecta_idioma() {  if($_SESSION["IDIOMA"]["actual"]=="")   {
        $_SESSION["IDIOMA"]["actual"]="ES";
        $_SESSION["IDIOMA"]["abreviatura"]="";
        $_SESSION["IDIOMA"]["nombre"]="Español";
        $_SESSION["IDIOMA"]["tag"]="ES";    }   if($_GET["action"]=="idioma" &&
 $_GET["lang"])     {       unset($_SESSION["IDIOMA"]);
        switch($_GET["lang"])       {           case "EN":
                $_SESSION["IDIOMA"]["actual"]="EN";
                $_SESSION["IDIOMA"]["abreviatura"]="_en";
                $_SESSION["IDIOMA"]["nombre"]="Ingles";
                $_SESSION["IDIOMA"]["tag"]="EN";            break;          case "ES":          default:
                $_SESSION["IDIOMA"]["actual"]="ES";
                $_SESSION["IDIOMA"]["abreviatura"]="";
                $_SESSION["IDIOMA"]["nombre"]="Español";
                $_SESSION["IDIOMA"]["tag"]="ES";            break;
                    }   }   $IDIOMA=array("actual"=>$_SESSION["IDIOMA"]["actual"],"ab"=>$_SESSION["IDIOMA"]["abreviatura"],"nombre"=>$_SESSION["IDIOMA"]["nombre"],"tag"=>$_SESSION["IDIOMA"]["tag"]);
    global $wp_rewrite;
     $wp_rewrite->set_permalink_structure($_SESSION["IDIOMA"]["tag"].'/%category%/%postname%');
    return $IDIOMA; }  add_action('init', 'detecta_idioma'); ?>

works well on the route entries, eg www.misitio.com/en/post-demo, t not working with pages or categories or taxonomies, eg: www.misite.com/es/category/, www.site.com/es/page/subpage or www.site.com/br/taxonomy <----- Dont work, shows error 404 page

I can not use the plugin qTranslate and CMS plugin multulengual either they do not work well with the use of plugins Advanced custom fields and custom post types UI.

Thanks