Multiple URL for one post

I am currently struggling with WordPress and rewrites. I hope you can help me a little.

Following situation:

  • I build a small plugin that does the following:
    • register a new post type (called “shop”)
    • create a post of this post type (post is called “shopinstance”)
    • add content to this post
      • content is some javascript where the JS mounts a shop (the shop supports pushstate URL) into this post

What does work:

  • I can access the post via the URL {domain}/shop/shopinstance. This works perfectly fine

What does not work:

  • I can NOT access the post via the URL {domain}/shop/shopinstance/product.

What my intention is:

  • The URL {domain}/shop/shopinstance/product-123 or {domain}/shop/shopinstance/product-abc should load the content that is placed in {domain}/shop/shopinstance/ so that the shop that is on this page can use the /product to identify what content to load
  • Therefore the URL should be kept but it should be “mapped” to the post

Side conditions:

  • It should be fixed from within the plugin
  • I do not want to change functions.php/htaccess or something else

I played around with add_rewrite_rule but I can’t get it to work. 🙁

Read more here: Multiple URL for one post

Leave a Reply

Your email address will not be published. Required fields are marked *