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

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

Your Answer


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

Browse other questions tagged or ask your own question.