can you use post_id as product slug?
-
I Want the slug of my products to be numbers.But when I change the slug of the product to a number, upon viewing the item it redirects to my shop page.
For example I would go to my shop page:
example.com/products/
I would see all the products. Then I would click on a product that has a slug of 4858:
example.com/products/4858
But the shop page would display instead of the item.
I tried added a rewrite rule:
add_action( 'init', 'productview_rewrite_init' ); function productview_rewrite_init(){ add_rewrite_rule( '^products/([0-9]+)/?', 'index.php?product=$matches[1]', 'top' ); }
Because, if I go to example.com?product=4858 in the url, it will redirect to the product page of that item.
My permalink setting in woocommerse is Shop base and my shop page is called **products**. My setting for wordpress uses Post name.
Is there anyway to use the post_id as permalink in woocommerce?
- The topic ‘can you use post_id as product slug?’ is closed to new replies.