• Resolved leskam

    (@uzumymw)


    Hello,
    is it possible to connect add_rewrile_rule function with WPGlobus?

    I mean I would like to create rule with current language parameter option:

    domain.com/{clear, en, ru etc}/my-own-rule/blabla/123/

    When default language

    domain.com/my-own-rule/blabla/123/

    When set language to en:

    domain.com/en/my-own-rule/blabla/123/

    https://wordpress.org/plugins/wpglobus/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author TIV.NET INC.

    (@tivnetinc)

    Hello,

    In your example, what exactly is “my-own-rule”?

    If that’s a page or category, for example, then WPGlobus will work exactly as you said: by adding the language prefix.

    If that’s something else then what is it?

    Thanks

    Thread Starter leskam

    (@uzumymw)

    Probably badly I explained what I mean.

    I created plugin with new type of pages with my own rewrite_rules via add_rewrite_rule WordPress function.

    When I use my own rewrite_rules with main site language everythink works fine, but when i change language e.g. to English (en tag in url) rewrite rules not working. So my question is that whether I must create another add_rewrite_rule’s hooks for rest of languages or WPGlobus got function for quick resolve this ?

    Plugin Author TIV.NET INC.

    (@tivnetinc)

    WPGlobus modifies home URL according to the current language. Maybe when your rules are processed, WPGlobus did not process that part. Theoretically, everything should work, but it’s hard to say something without looking into the code.

    Thread Starter leskam

    (@uzumymw)

    My example of function add_rewrite_rule:

    add_rewrite_rule('^account/cart(/|)$', 'ecommerce.php?account&option=cart', 'top');

    When I put on browser address like: domain.com/account/cart it works good but when i change language e.g. to EN
    domain.com/en/account/cart not working.

    WPGlobus does not support add_rewrite_rule WordPress function ?

    Plugin Author TIV.NET INC.

    (@tivnetinc)

    1. When do you issue that call? When your plugin is loaded? After the plugins_loaded hook? On init? On wp_loaded?
    2. I wonder if removing ^ would help.
    3. Have you tried rewrite rules in .htaccess instead?
    4. Let’s assume that you have the rule working after checking 1,2, or 3. You will arrive at ecommerce.php. What happens after? Is that a WordPress script at all? How are you going to continue with multilingual then?

    > WPGlobus does not support add_rewrite_rule WordPress function ?
    WPGlobus, probably, does not need to support that function. It needs to support what happens after the rewrite is processed. And for that, all it needs is to have a correct prefix: /en/, /fr/, and so on.

    Thread Starter leskam

    (@uzumymw)

    I call this issue on add_action(‘init’, […]); on plugin .php script

    I’ve just edited rewrites only by WordPress function except .htaccess (WordPress do that)

    My “target” is use ecommerce.php file by add_rewrite_rule regardless of the selected language. I want to use /account/cart for each language ( /en/, /fr/ etc)

    Plugin Author TIV.NET INC.

    (@tivnetinc)

    Adding these lines to .htaccess should work:

    RewriteEngine on
    RewriteBase /
    RewriteRule ^([a-z][a-z]/)?account/cart/?$ /ecommerce.php [L,R=301]

    It will work faster than going through WordPress for rewrites.

    P.S. The same regexp might work with add_rewrite_rule (I haven’t tried it).

    Thread Starter leskam

    (@uzumymw)

    Wow its working! (In add_rewrite_rule too)

    Thanks!

    I’ve got another question because I can’t found page with list about all WPGlobus functions. Is it exists ?

    Plugin Author TIV.NET INC.

    (@tivnetinc)

    ..page with list about all WPGlobus functions

    No, sorry. WPGlobus and its extensions are growing too fast. Such list would become outdated the minute we publish it… 🙂
    But, the code is open-source and commented. You can run a PHP Documentor to get the list, I believe.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Own rewrite rule pages with WPGlobus option’ is closed to new replies.