This should work:
add_action( 'init', 'wpse33551_rewrites_init' );
function wpse33551_rewrites_init(){
add_rewrite_rule(
'product/.+\-([0-9]+)?$',
'index.php?post_type=product&p=$matches[1]',
'top' );
}
The filter function is changing the permalink to like product/my-product-name-88
. You just need to tweak the regex in the second function to deal with that pattern.
The regex is:
product/
– matches the literal string product/
.+
– matches one or more other characters
\-
– matches a hyphen (the backslash escapes it, so the regex engine doesn’t think it’s a special regex operator, like in the next bit)
([0-9]+)?$
– matches and captures one or more numbers at the end of the URL
As @gregory says, after making this change you need to click the save button on your permalink page wp-admin/options-permalink.php
to flush the rewrite cache.
Related Posts:
- Get the product list of a given Category ID
- get woocommerce My account page link
- Correct function to get the user’s latest Woocommerce Subscription?
- Move payment options at checkout in WooCommerce [closed]
- Where do the cart details are stored in database?
- WooCommerce – Hook after Loading Variation in Admin Edit page?
- Fetch Product information in WooCommerce
- New endpoint in my account gives 404 Error Woocommerce 3.6.5 and WP 5.2.2
- Add Custom CSS to Woocommerce Product Page in a specified category
- wc_get_product in a none woocommerce page
- How to echo billing phone number under My Account in Woocommerce? [closed]
- Unknow php file in wordpress core [closed]
- woocommerce_get_price filter hook not working for product variation price
- Woocommerce SKU on ALL products page [closed]
- Stop WooCommerce from updating user/user meta after checkout
- Displaying Custom Input Value to Customer Order Details (My Account) page in Woocommerce
- Woo API REST : product variation price is read-only?
- Get rid of product images mobile swipe functionality from WooCommerce single product [closed]
- How to upload Woocommerce product images via API? [closed]
- how to do a processing Orders into Complete after x Minutes or x hour in WooCommerce [closed]
- Custom Admin Email Subject for Woocommerce (3.8.0) Orders
- Woocommerce custom endpoints
- Force uppercase on some WooCommerce checkout fields input
- Display custom field without plugin in woocommerce
- How to output php between header and woocommerce container
- WooCommerce – How can I make single product gallery show two images on the slider at once?
- How to delete all customer user account that haven’t placed a single order?
- How do I add an extra field to comment form above the submit button?
- woocommerce email template detect email recipient
- WooCommerce – buying as well as selling
- How do I hide ‘out of stock’ products in the admin ‘product’ page?
- Hide the prefix before the price of the product [closed]
- Backend users list – add Woocommerce meta to table
- Add custom field to Woocommerce add new attribute / edit page
- woocommerce axios react
- Woocommerce hook on address field change [closed]
- Maintenance mode just for WooCommerce shop pages [closed]
- Woocommerce – Add HTML around Product description [closed]
- relocate woocommerce notices/messages on Cart page
- Custom email template for a specific product category
- lost password link not working for my site
- How to give each category name its own ACF background color?
- WooCommerce 4: Gallery size is too large in mobile
- Same request Mysql/Php not same result
- WooCommerce Registration redirect based on page ID
- Filter default_content only for products
- Get woocommerce coupon code
- Woocommerce change price in cart when discounted
- Remove Visual Editor and P tags from WooCommerce Taxonomy Descriptions [closed]
- Woocommerce Remove Tax by Product Type
- get_posts $args won’t accept array as one of the criteria?
- WooCommerce print subcategory of product
- Woocommerce – sell a certain category by unit, another by weight? How?
- Add custom parameters to Woocommerce add to cart link
- How to automatically change the status of product from draft to published when stock qty change from 0 > 1
- Update WooCommerce Sale Price & Date Based On Attribute Value
- Add quantity of variations together and show it to parent quantity field Woocommerce
- Woocommerce: How to change the attribute values per product
- Delete method giving 500 error, for this endpoint /wc/store/cart/items
- In woocommerce product details not showing
- Re-arrange the Woocommerce checkout page layout
- How to sort products by price ASC and place all no price products to the end? (Woocommerce)
- WordPress | Woocommerce | use “category display type” in if statement
- Parameters in woocommerce_before_add_to_cart_button hook
- Update / refresh mini cart, after custom AJAX add_to_cart event
- How can I get a get a list of customers from a list of email addresses?
- WordPress Woocommerce Endpoint URL
- Will ‘private’ status prevent Woocommerce products to be indexed by search engines?
- Woocommerce: sorting variable product
- Remove filter parameter from Link URL
- Add to cart is not visible in product page
- Notice: Trying to get property of non-object in
- French accented text replaced with ? in woocommerce product list
- add_action don’t updates theme layout when using values from the WordPress customizer
- How can I change my search form to bring up product results, not blog results
- Prevent user from changing any account data once it is setup
- Redirect After Registration on Specific Link
- Incorrect translation of ‘shipping’ at woocommerce checkout page after WC update 3.4*
- Sell a WooCommerce Product on Content Pages
- How can you get woocomemrce to give you multiple licensing options for a downloadable product?
- WordPress media library don’t load most of the photos in library
- Show “email already used message” first
- Can I get some product is virtual in Woocommerce by hook?
- Woocommerce order_complete email dont send after changing order status via sql
- delete cart item from the carts when user login from other system
- Site doesn’t work when updating to SSL using nginx
- Getting one specific value from get_children array
- Add text specifically to order-proceessing-email in WooCommerce
- Cannot Modify Header Information error
- How to hide metaboxes in WordPress Admin on WooCommerce “Add Product” page – Remove side sortables for a specific user role
- woocommerce breadcrumb only in cart and checkout pages
- WooCommerce REST API endpoints don’t exist
- woocomrce pay here button help
- Woocommerce in a subdirectory [closed]
- exclude products none sale in Woocommerce
- AffiliateWP not calculating multiple quantities when using affwp_calc_referral_amount filter
- Hide a shipping method if cart total is higher than an amount
- error 500 in Back Office when using a woocommerce function in functions.php
- How to update all products with same SKU prefixes when updating stock with CSV?
- What is the best and cheapest way to generate dashboards about conversions data and store users? [closed]