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

A client wants certain posts to have a custom permalink structure. Client is running WordPress 2.8.5 and upgrade is not currently an option, so I can't use a custom post type. That being the case, it seems I must use a category to create the custom structure.

So, I need the site-wide structure http://example.com/%post_id%/%postname%/ to turn into http://example.com/%postname%/ just for posts in the one category.

I gather that I need to use add_rewrite_rule to change the permalink. But I'm having trouble changing the URL structure at all adding rules to functions.php, and I don't understand regex well. Can I filter for a generic structure such as %post_id%, or only strings? Can anyone provide some guidance as to how I may accomplish this goal?

share|improve this question
Why is upgrading not an option? – shea Feb 4 '13 at 0:59
a couple of things- adding a rewrite rule only handles the incoming requests, you also need to filter post_link to generate the proper permalinks for these posts. that said, I think you're going to have some issues trying to achieve this structure, if you add a rewrite rule to catch /%postname%/, you'll also intercept the page post type. can you not just use pages for these instead of posts? – Milo Feb 4 '13 at 1:03
Client is scared of upgrading hassles and associated downtime. I suggested an upgrade and custom post type.. they just want to 'keep this project simple' and do an upgrade later. Tl;dr, its their decision. – spogue Feb 4 '13 at 5:09
I was thinking of logic something like, if category is x then rewrite permalink to remove postID. Possible? – spogue Feb 4 '13 at 5:17
I don't think pages will work. These posts are supposed to behave like regular posts, except with a different template and permalink. – spogue Feb 4 '13 at 5:32

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.