开发者

Virtual pages for my plugin

开发者 https://www.devze.com 2022-12-31 22:25 出处:网络
I am currently in the process of making a WordPress Plugin which is going to parse some external data (products) from various web services and present them as normal pages in WordPress.

I am currently in the process of making a WordPress Plugin which is going to parse some external data (products) from various web services and present them as normal pages in WordPress.

I would like to avoid actually creating the pages programatically and instead just generate them on the fly to avoid any synchronization issues if a product is deleted and so forth.

My plugin is going to have a base url in which it will hook on to, for example /pro开发者_C百科ducts/, and then I would generate each product page by calling /products/some-product-name/. I also anticipate the need for uri's like /products/category/some-category-name/ which I will use to list all items in that category.

Since I am new to WordPress plugin development, I am looking for some tips and advice to get me started on the right foot. Any help is highly appreciated ;)


I suppose it really depends on where/how you're getting your info from these web services, but I can imagine that the easiest way would be to setup a page as a controller and have it parse out some RSS or XML to build these "virtual pages" by request, so that you're not storing anything in the DB and if the info requested doesn't exist than yes 404 it.


I solved this by adding a filter to rewrite_rules_array and an action catching template_redirect.

0

精彩评论

暂无评论...
验证码 换一张
取 消