WordPress.org

Ready to get started?Download WordPress

Forums

MarketPress - WordPress eCommerce
Marketpress url rewriting with fixed argument count (1 post)

  1. cyngate
    Member
    Posted 1 year ago #

    I managed to add taxonomy category to product url making to show localhost/products/office/table/product with the help of this url

    How to create a permalink structure with custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type-name
    http://wordpress.stackexchange.com/questions/39500/how-to-create-a-permalink-structure-with-custom-taxonomies-and-custom-post-types/39862#39862

    May i know how to make the site url with fixed param translation with a custom one.

    May i know how to make the site url with fixed param translation with a custom one.

    TLDR:

    what my problem is, i have
    localhost/products/office/chair

    it tries to convert this link to
    localhost/?product=chair
    but i would rather it to do
    localhost/?product_category=chair

    same with a link with three argument
    localhost/products/office/chair/productA
    localhost/?product=productA

    a link with one argument
    localhost/products/office/
    localhost/?product_category=office

    when i try to switch to

    $newRules['products/(.+)/?$']    = 'index.php?product_category=$matches[1]';
         $newRules['products/(.+)/(.+)/(.+?)'] = 'index.php?product=$matches[2]';

    from

    $newRules['products/(.+)/(.+)/(.+?)'] = 'index.php?product=$matches[2]';
        $newRules['products/(.+)/?$']    = 'index.php?product_category=$matches[1]';

    it became like this, the subcategory work but the product will not be found
    localhost/products/office/chair/productA
    this converts to
    localhost/?product_category=productA
    an customized search not found is outputed from my custom-taxonomy(category) page

    but this time i want it to become
    localhost/?product=productA

    so if there is a third argument, i want to to become
    localhost/?product=productA
    if there is only two argument in the link, i want it to become
    localhost/?product_category=chair

    product_category is registered

    register_taxonomy( 'product_category', 'product', apply_filters( 'mp_register_product_category', array("hierarchical" => true, 'label' => __('Product Categories', 'mp'), 'singular_label' => __('Product Category', 'mp'), 'rewrite' => array('slug' => $settings['slugs']['products'],'hierarchical'=>'true')) ) );

    and custom post type is registered as follow

    'publicly_queryable' => true,
                'capability_type' => 'page',
                'hierarchical' => false,
                'rewrite' => array('slug' => "products/%taxonomy_name%", 'with_front' => false,'hierachical'=>true), // Permalinks format
        		'query_var' => true,

    http://wordpress.org/extend/plugins/wordpress-ecommerce/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic