marketpress adding .html extension to product
-
I managed to add taxonomy category to product url
making to show
localhost/products/office/table/product
through the help of this url
wordpress.stackexchange.com/questions/39500/how-to-create-a-permalink-structure-with-custom-taxonomies-and-custom-post-typeshowever i faced a problem with (sub-category/taxonomy)
meaning if i go to localhost/products/office/table
wordpress will tries to look for product “table” which in my case should be a subcategory hence a return of 404 page.In my case, my category tree should look like this
there are 2 level category, with only one parent category and multiple subcategory and then product- Office
- Chairs
- productA
- productB
- Table
- productC
- productD
- House
add_filter('rewrite_rules_array', 'mmp_rewrite_rules'); function mmp_rewrite_rules($rules) { $newRules = array(); $newRules['products/(.+)/(.+)/?$'] = 'index.php?product=$matches[2]'; // my custom structure will always have the post name as the 5th uri segment //$newRules['products/(.+)/?$'] = 'index.php?product_category=$matches[1]'; //$newRules['products/?$'] = 'index.php?product_category=$matches[0]'; return array_merge($newRules, $rules); }
i tried to add .html here
$newRules['products/(.+)/(.+)/?\.html$'] = 'index.php?product=$matches[2]';
and append .html to the filter_post_type_link filter functionthe result is
subcategory work now, custom post type is added .html
but product failed to be queried.
when i switch the permalink setting back to default
i noticed the product page link became
localhost/?product=table.html
which is supposed to be
localhost/?product=table
- The topic ‘marketpress adding .html extension to product’ is closed to new replies.