Have Plugin Handle Specific URLs

Does WordPress have the ability to use the currently defined template to serve up content in the database?

For example, I have a database of a bunch of custom content– the name of an item, the price, etc.

Read More

I want all requests for http://myshop.com/buy/* to be redirected to the plugin (so that the plugin handles the content generation), where the * is an item number or some other parameter. Can I use the WordPress template and display my custom content? I would be handling all of the HTML generation for inserting into the template…

The best example I can find is the WP Ecommerce plugin here: http://getshopped.org/. Basically, the plugin is handling the checkout page (/checkout in most cases, /icons/checkout on IconDock). How can I do this?

Related posts

Leave a Reply

2 comments

  1. There are two different things happening here. I’ll start with your second example, as that’s easier.

    Most shopping carts, in your example WP-Ecommerce, create placeholder pages with a shortcode for things like the cart page and checkout page. All they’re doing to handle that is creating a shortcode function and inserting it on a page, then outputting whatever they need to in the shortcode function. In this case the shortcode is static, and there isn’t any other data being passed via the url. The actual product pages in WP-Ecommerce are just a WordPress custom post type with some extra meta data.

    What you’re talking about, creating your own url structure via a plugin to pass data, involves writing your own rewrite rules via the WP_Rewrite class and inserting your own query vars.

  2. in short … wordpress can be made to do just about anything …not 100% sure but it sounds like you’re looking for custom post types – check out this video http://vimeo.com/10187055 – ( it’s actually a plugin that builds the custom post types for you but you can build them yourself with the code – you will probably need to do this but the plugin in the video allows you to play with them so you can see the capabilities – not too difficult just google “custom post type” and also wordpresss taxonomy )

    btw the wordpress irc on freenode can be helpful for this type of thing