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 had asked this question in a different way too, but no one replied there! I guess I should rephrase it here.
My custom post is 'company'. I'm trying to add a custom rewrite rule. When the 'url http://domain..com/company/company-title-slug/replies', is accessed, I want redirect to a custom template(applied to a page named 'replies') with all the comments for this custom post listed. If I add the comment id in the url like this 'url http://domain..com/company/company-title-slug/replies/23', I want to redirect to another page with a custom template applied for displaying a single comment.

This is what I did for accessing the url... 'http://domain.com/replies/reply_id', and it works fine.


Please guide me in the proper direction, having a real hard time with the url rewrite stuff!

Thanks in advance!

share|improve this question
up vote 1 down vote accepted

I haven't tested it, but what about:

share|improve this answer

Using add_rewrite_rule only is not enough. It only adds a new rewrite rule to WP. But you need to register new query variable (in your situation, it's reply_id) and parse the request to catch that query variable.

Jan Fabry has posted a detailed sample for creating custom rewrite rule, I think it contains all you need.

share|improve this answer
Thanks guys. I ended up using a solution similar to the solution by @devin. Now I can access the url as 'domain.com/company/post-slug/replies/comment_id'; (exactly how I wanted it). But what I was trying to achieve is, when I access the url 'domain.com/replies/comment_id';, then the permalink should change to 'domain.com/company/post-slug/replies/comment_id';. I guess I need to change the permalink using the post_type_link filter. – Rutwick Gangurde Aug 20 '11 at 4:03
I added the new variable using 'query_vars' filter, and getting it using 'get_query_var'. – Rutwick Gangurde Aug 20 '11 at 4:04

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.