WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working on a plugin that creates an inventory list page using an XML data file. For the sake of this example, let us say the inventory items are antique motorcycles or contemporary area rugs.

User activates my plugin and adds a short code to a page in order to display the inventory on a page called "Inventory."

I want to introduce a details page so when the end user wants to enlarge the thumbnail picture or read more details about a specific motorcycle, he can click from site.com/Inventory to site.com/Inventory/somethingelse/ to find that information on another page.

What is the right way to code this? Some things I have considered are...

  • Create another page and another short code and then hide the page from the menus
  • Add rewrite rules to send these requests to a .php file in my plugin directory

What do you think?

Thanks for reading.

share|improve this question
up vote 0 down vote accepted

Create a custom post type inventory. You get a separate post editor, nice URLs for free. No need for a short code, because each post type has its own archive page. You may add custom meta data, taxonomies etc.

Write an importer. Look at the WordPress importer, it uses XML too. This isn’t very hard, just make sure the post type and all additional meta data are already registered.

share|improve this answer
This is interesting. I would need an update routine, too. The XML file needs to be imported at least once a day, so I would be in the business of updating posts in addition to creating and deleting. – rg89 Feb 14 '12 at 14:30

What you're trying to build is a fairly in-depth plugin, assuming it's something you want to integrate with WordPress at all. I'm assuming here that the user isn't ever updating the XML data from inside WordPress, but the fact that you want the user to be able to display data using shortcodes means that you'll need some integration.

Because you're looking to take control of URLs like site.com/Inventory/somethingelse/, you'll need to look at adding your own rewrite rules using add_rewrite_rule(). You'll then need to add custom actions to control what happens when users access a specific re-written URL (parse_request and template_redirect are where I'd look first). You'll also need to package your own XML parser, as WordPress doesn't come with one (beside SimplePie, although that's specifically for RSS).

One example you might want to look to for this is NextGEN Gallery. It does similar sorts of things in that it has custom URL handling for single images. It also uses XML and JSON for setting up image rotation queues, so you can take some leads from that as well.

I wish you luck with this. If you need more help, it would be best to break your problem down into smaller chunks and ask individual questions for each. Walking through the whole process of building a plugin like you describe is well outside the scope of a single question.

share|improve this answer
In-depth but not very large. Most of it is already running. I am using SimpleXML right now which I know will cause compatibility issues with hosts. My plan is to write the detail page today. Thanks for the tips. – rg89 Feb 14 '12 at 14:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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