Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

So here's what I'm trying to do. I'm building a plugin for a business directory. Each business is assigned to a category. There are two views, listing and detail. To give the user as much flexibility as possible, I have created a shortcode where they can pass in the category and that will display the listview. This works great. They can create a page, called "Fishing" with a permalink of "/fly-fishing" and the content is

   Here's some title information about our fishing.  Thanks yadda yadda.
   [business-directory category=fishing]

Notice that the category and the permalink are different. Again, to show the flexibility I'm trying to achieve.

In my listings, I would like a permalink to each business that uses the permalink of the category page that they select. So one might be /fly-fishing/abc-fishing. When that permalink is visited, I need my plugin to know that the category is actually fishing and the business is abc-fishing.

I'm having trouble with creating the add_rewrite_rule such that it knows what page to pass back to. My thought was to query each page, look for my shortcode, and then add the rewrite_rules accordingly. This means I will have to do this on every page creating/update.

Is there a better way?

share|improve this question
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.