• Hello,

    I am having trouble getting the plugin to work properly with polylang.

    Basically permalinks (no matter how many times I regenerate them) are not working properly for the view/ and share endpoints.

    It works if I set polylang URL modifications to “Language is set from content”,

    so the wishlist page is /my-wishlist/ and /my-wishlist/view/ /my-wishlist/view/{share-id} all work fine.

    But using that setting means I can’t have translations for the UI elements of Woocommerce using ”
    Hyyan WooCommerce Polylang Integration” plugin since as its readme mentions: “Polylang URL modifications method The language is set from content is not supported yet”.

    If I switch to “The language is set from the directory name in pretty permalinks” in polylang, woocommerce translations work fine but /{lang}/my-wishlist/view/ /{lang}/my-wishlist/view/{share-id} now return 404 errors.

    Any ideas? Even if I have to hardcode the relevant rewrite rules.

    Alex

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter clockwork.gr

    (@clockworkgr)

    In case anyone runs into this issue:

    Fixed it by hardcoding the relevant permalinks.

    Auto generated ones are:

    [(([^/]+/)*{wishlist-page-slug})(/(.*))?/page/([0-9]{1,})/?$] => index.php?pagename=$matches[1]&wishlist-action=$matches[4]&paged=$matches[5]
    [(([^/]+/)*{wishlist-page-slug})(/(.*))?/?$] => index.php?pagename=$matches[1]&wishlist-action=$matches[4]

    Just add your language ones with the lang prefix in functions.php as follows:

    
    function YITH_polylang_rewrite_rules() {
        //Lang 1
        add_rewrite_rule('{lang1-slug}/(([^/]+/)*{wishlist-page-lang1-slug})(/(.*))?/page/([0-9]{1,})/?$','index.php?pagename=$matches[1]&wishlist-action=$matches[4]&paged=$matches[5]');
        add_rewrite_rule('{lang1-slug}/(([^/]+/)*{wishlist-page-lang1-slug})(/(.*))?/?$','index.php?pagename=$matches[1]&wishlist-action=$matches[4]','top');
        //Lang 2
        add_rewrite_rule('{lang2-slug}/(([^/]+/)*{wishlist-page-lang2-slug})(/(.*))?/page/([0-9]{1,})/?$','index.php?pagename=$matches[1]&wishlist-action=$matches[4]&paged=$matches[5]');
        add_rewrite_rule('{lang2-slug}/(([^/]+/)*{wishlist-page-lang2-slug})(/(.*))?/?$','index.php?pagename=$matches[1]&wishlist-action=$matches[4]','top');
        // .... and so on
      }
      add_action('init', 'YITH_polylang_rewrite_rules', 10, 0);

    Alex

    Thank you Dude,

    Your hack also solved my issue!

    Have a nice day!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Polylang Compatibility: Permalink Issue’ is closed to new replies.