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 am trying now for a couple days to solve the following Problem:

I have a custom post type called gallery. I need the URL


to be parsed like


The Permalink Setting for custom post type is:


I think I have tried about every code snipped that I could find to solve this problem but nothing seems to work.
If I flush all rewrites, none of my links work anymore (404)

Is is even possible?

share|improve this question

I think it should work. First you need to register your rewrite rule and the parameter:

function my_init() {
        'top' );
add_action('init', 'my_init');

Then you can read the parameter value from the query:

$param = get_query_var('param');

Don't forget to flush the rewrites. (just view the rewrite settings page to flush the rules)

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.