Look at the filter for rewrite_rules_array and add a re-write rule to re-write /products/category-name/sub-category-name/product-name to index.php?pagename=product-name. You might need to grab the category-name and sub-category-name too if your product-names are not unique.
Then add a query var for product-name using the query_vars filter.
Once you’ve done that in your new post type template you can just access the product-name query var (and the others) using get_query_var. And display the correct record.
Without coding the answer for you that’s and outline of how I’ve done exactly what you’re trying to do.
Related Posts:
- How to display by default only published posts/pages in the admin area?
- Find out who deleted a page or post?
- Post/Page Preview Template
- Using single.php from plugin folder instead of default template folder
- using wp_update_post on save_post
- WordPress plugin to publish to multiple remote WordPress blogs
- How to disable drafts?
- Custom Post Type Pagination Doesn’t Work in WordPress 3.4
- How to wrap every image in a post with a div?
- Post from front-end only by logged in users, form posts as “posted by:
- Show One Category on Post
- WordPress Delete hook with wp_delete_post function?
- Order post by year DESC and month ASC
- Why does `url_to_postid` return 0 when testing `page_for_posts` Page?
- Do I use custom post type or something else?
- how “manage_posts_custom_column” action hook relate to “manage_${post_type}_columns” filter hook?
- Delete Post From Front-End and attachment permanently
- if custom post type exist
- Custom post type permalinks breaking due to 3.1 bug fix
- ‘Invalid post type’ error when importing from one site to another
- Blogroll – Different layout for first post
- How to delete old posts’ edits to save space?
- Remove slashes (both before and after) in relative post url
- Archive Page for Custom Post Type is not Working
- Filter Custom Post Type by Category with Ajax
- Edit custom post type admin menu link
- How to include a post type in the admin/backend?
- How to make number of blog posts a custom field?
- WordPress blog or WordPress website
- Hiding Draft Post In Admin
- Show posts by a custom post author
- Search results posts_orderby and ID
- Making a custom Pagination for multi page blog post
- Unable to restore from backup – how to obtain old blog posts?
- Permission issue with custom post type – not added to menu – by plugin
- Remove Custom Post Type Slug and add Custom Taxonomy to Permalink Structure?
- custom post template file not shown, instead all the time 404.php
- Custom Post Type Rewrite To Include Parent Page(s)
- Thumbnail & Category link aside post
- Is it possible to customize the post according to post format in single.php?
- Custom taxonomy archive page problem
- Is there a way to create a meta box that can be added multiple times to a post dynamically?
- Custom Post Type archive
- WordPress custom post type with folder structure in slug
- How to add automatically bootstrap 4 order-lg-1 and order-lg-2 classes for columns in foreach loop based on the count?
- How to add convenient buttons for new custom post statuses
- Show custom post with custom categories with specific slug
- Auto delete posts based on content text
- How to call posts under a specific category on static front page?
- Display value of custom field at the beginning of a post
- datepicker value in mysql
- Optimize CPT-function with a loop
- Add post tags to previously created custom post type
- How to display only one category in a custom post type?
- How to restore deleted post related with deleted users
- add_rewrite_rule and template redirect not working
- Changing permalink of WordPress
- Hook save_post_cpt not triggered when custom fields are modified
- Change modified date to current date when title updated automatically
- Turn off display for custom sidebar post widget when on the post it’s displaying
- How to bulk Update URLs to new values?
- How to put the author of the post in the comments?
- How to add a custom class attribute into code wrapper? [duplicate]
- Redirecting wordpress search query to archive page
- Include Recent Post in Category
- Pagination Not Working With Custom Post Type Category
- WordPress Pods Custom Post Type – separate Media Upload folder for each custom Post Types
- Hide or remove custom post status
- Put page on Archived statut after end of publication date
- post and page and custom post type
- My posts page is missing the page title
- Show custom post category for single post
- How can change header text in post careate/edit form
- How to get meta data from custom category name
- Add Categories To Custom Post
- How do I set content in my pages so that it remains permanent while blog posts are added below?
- how to redirect page after delete post inside a post page?
- Permalink base only for posts
- Difference between modified post and new post
- Creating widget – ask for selecting a post in the admin panel
- issue in wordpress auto delete post and redirect to another 1
- wp query custom orderby not custom field
- Customizing individual images on posts
- How to retrieve custom field values and save again as array
- Custom Single Post Type not referring to single-post-type.php File
- Is there a Standard Format for Clean URLs for Archives of Custom Posts?
- How to modify specific parts of a post content in WordPress
- Include post on external custom site
- Run Jquery Script after delete post in front end
- Checking if some condition is matched before inserting post into database
- Successive creation of over 1000 posts causes 404?
- Custom Post Title as search term
- How can I allow users (subscribers) to download selected posts into a single PDF? (RESOLVED)
- Best way to enable sorting by 3 criteria on a page of listings
- How remove “recent comments” title without modifying code? [closed]
- Default post type doesn’t display in url
- How do I get content of custom post type through post ID
- Notify/check if the content of a custom gutenberg block has changed on save_post
- WordPress Custom Post type csv exporter
- Edit Page button is gone