• Resolved majnoon123

    (@majnoon123)


    Hello

    i am using the plugin more then a year and i think this is the best plugin which is free and provide all feature which premium plugin have.

    i am using WooCommerce for my website and i have two Lang one is English and second is Arabic so i want to remove product category name from permalink and found a code on internet the code work great but it also remove language permalink so can u please solve the problem before this code my website is like website.com/en/prodcut_category/laptop and then i add the code my permalink should me website.com/en/laptop but the code remove en also and when i click the link i got a 404 error and when i type en on manual in url bar it work

    here is the code

    <? php // Remove product cat base add_filter('term_link', 'devvn_no_term_parents', 1000, 3); function devvn_no_term_parents($url, $term, $taxonomy) { if($taxonomy == 'product_cat'){ $term_nicename = $term->slug; $url = trailingslashit(get_option( 'home' )) . user_trailingslashit( $term_nicename, 'category' ); } return $url; } // Add our custom product cat rewrite rules add_filter('rewrite_rules_array', 'devvn_no_product_cat_parents_rewrite_rules'); function devvn_no_product_cat_parents_rewrite_rules($rules) { $new_rules = array(); $terms = get_terms( array( 'taxonomy' => 'product_cat', 'post_type' => 'product', 'hide_empty' => false, )); if($terms && !is_wp_error($terms)){ foreach ($terms as $term){ $term_slug = $term->slug; $new_rules[$term_slug.'/?$'] = 'index.php?product_cat='.$term_slug; $new_rules[$term_slug.'/page/([0-9]{1,})/?$'] = 'index.php?product_cat='.$term_slug.'&paged=$matches[1]'; $new_rules[$term_slug.'/(?:feed/)?(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?product_cat='.$term_slug.'&feed=$matches[1]'; } } return $new_rules + $rules; }
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author sbouey

    (@sbouey)

    The 404 is normal you didn’t add rewrite rules for this specific configuration

    can you give me a screen capture of the permalink , the section Product permalink. To reproduce this configuration locally

    Stéphane

    Plugin Author sbouey

    (@sbouey)

    Locally i have configured Falang and Woocommerce without any change to remove the categorie in the url

    Before i have that (display categories) with url like “falangw/fr/shopfr/robe/noire-fr-wire-frill-long-sleeve-sheer-blouse/” you can see here robe translation in french of dress in the url

    The permalink

    https://snipboard.io/MY7hm1.jpg

    and Falang > Settings > Translate Options > Products (options popup)

    https://snipboard.io/xOMinD.jpg

    I have change the configuration in this popup option page to

    https://snipboard.io/mFAYfl.jpg

    after that the url become

    “falangw/en_us/shop/black-wire-frill-long-sleeve-sheer-blouse/”

    “falangw/fr/shopfr/noire-fr-wire-frill-long-sleeve-sheer-blouse/”

    The categorie is no more in the url

    Thread Starter majnoon123

    (@majnoon123)

    thank you for replay sbouey

    yes the category name is not showing in product page but it show in categories page i can change this name from setting Translate Taxonomies but i want to remove complete from permalink

    https://snipboard.io/nNYqOb.jpg

    please check the screenshot there is option to change the category permalink from here like i did i change and add cat name but i want to remove this name not to change or show in permalink

    majnoo.co/en/cat/

    majnoon.co/en/ <—– like this

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘permalink issue product category’ is closed to new replies.