• Hi,
    I have defined a permalink structure which looks like this :

    add_filter('post_type_link','product_permalink');
    $wp_rewrite->add_rewrite_tag("%product%", '([^/]+)', "product=");
    add_filter('post_type_link', 'producttitle_permalink', 10, 3);
    $wp_rewrite->add_rewrite_tag("%producttitle%", '([^/]+)', 'producttitle=');
    
    $products_structure = "/Products-DB/Reference-%product%/%producttitle%"
    add_permastruct('product', $products_structure, false);

    It works very well for now.

    Now, I want to add a query arg “COUNTRY” to this permalink, so that visitors can see the post content in ENGLISH, DANSK, FRENCH etc…

    the simpliest way is to use:
    $wp->add_query_var('country');
    then to pass it to WordPress with : http://www.mysite.com/Products-DB/Reference-0012/Product_Title_Sample/?country=ENGLISH

    I would like to use a pretty permalink like this :
    http://www.mysite.com/Products-DB/ENGLISH/Reference-0012/Product_Title_Sample/

    How can I do that ? Is add_rewrite_tag the best way to do that ?

    Thank you for your help,
    Looic.

  • The topic ‘Pretty query arg in custom permalink’ is closed to new replies.