I am developing a plugin where Admin can integrate the plugin to a page where newly added products will be shown.. So, let's say user add the plugin to a page named my-page.

So, the main content of the plugin will be shown in mysite.com/my-page/

Users can upload products and their uploaded products will be shown in mysite.com/my-page/user/user-name

The admin will have the ability to add custom fields to the products. If admin create a custom field named category, mysite.com/my-page/category/category-name will show all the products with the category, category-name. All the pages will also have pagination support to restrict products per page. So, I need to create a rewrite rule on fly, every time Admin create a new custom field.

I know how to rewrite URL and add custom query variables but in this case I don't know the page name where it will be inserted and custom fields will be inserted in the database. So, basically I need dynamic URL rewriting. Is this kind of rewrite possible?


I have done it like this. From the plugin admin menu, I have created option where user can select the page where they want to install the plugin. Based on the value selected, the URL rewriting was done and the selected page id is stored as an option field. I created two custom variable for this. The plugin serve template file for that page based on the value of the custom variables.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.