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 have the following URL structure:


id specifies the id of the post.

gallery is a normal page inside which I am accessing the id of the post and fetching the attachment images using WP_Query().

I want to replace the URL of this page to:


in which the parameters place and new-delhi may vary in multiple other options and topic is the keyword which remains the same.

I have tried using some unfruitful .htaccess file code.

Can anyone please help?

share|improve this question
Please edit your question and tell exactly where you've set topic, place, new-delhi and what they are (custom post type/meta data/taxonomy, etc.). – kaiser Oct 9 '12 at 12:25
topic is a page and place is a cpt and new-delhi is a post under 'place' cpt – Rohit Pande Oct 9 '12 at 13:21
"Please edit your question(...)" – kaiser Oct 9 '12 at 14:11
up vote 0 down vote accepted

I have tried some add_rewrite_rule magic and query variables and it worked. Thanks for the help everyone.

If in case anyone want to refer the answer:

add_filter( 'query_vars', 'wpse26388_query_vars' );
function wpse26388_query_vars( $query_vars ){
    $query_vars[] = 'custom_gallery_id';
    return $query_vars;

  'top' );

I was able to solve my problem with this.

share|improve this answer

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.