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'm having basically the same problem as question #44117. I have a custom rewrite rule set using add_rewrite_rule, but when the user goes to the page, the entered url changes and the value is lost.

User enters: membership/member-profile/profile-name/

And is forwarded to: membership/member-profile/

Here's my rewrite code:

function profile_rewrite() {
    add_rewrite_rule('membership/member-profile/([^/]+)/?', 'index.php?pagename=member-profile&profile=$matches[1]', 'top');
add_action('init', 'profile_rewrite');

I've been researching for hours, and while I've found others with a similar problem, there has never been a definite solution.

Maybe it's a problem with my Wordpress settings? If I enter the URL:


I'm forwarded to:


Which returns a 404 error.

Thanks in advance for any help. I'm pretty new to this Wordpress stuff and maybe I'm jumping in a bit too quickly.

share|improve this question
up vote 1 down vote accepted


    'top' );

should be:

    'top' );

the difference is pagename should contain the parent/child path.

also- if profile isn't a recognized query var, it needs to be added in order to be accessed:

function wpse47596_query_vars( $query_vars ){
    $query_vars[] = 'profile';
    return $query_vars;
add_filter( 'query_vars', 'wpse47596_query_vars' );
share|improve this answer
Thank you so much! Adding the parent fixed my problem and the value is even showing up. – Steven Apr 1 '12 at 20:08

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.