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 currently have these custom permalink rules:


I'd like /%category%/%postname%/%sometext% to display the same as /%category%/%postname%/ - from there, I will either use PHP or jQuery to display different content on the page.


/about-us/team/mike to display the /about-us/team page, and then I'll highlight 'Mike's bio' with jQuery.


share|improve this question
This is functionally identical to the use of # and IDs to auto navigate to places on a page, what you're trying to do sounds terribly like a kludge/work around. Why do you wish to do this? – Tom J Nowell Jan 15 '13 at 11:25
Mainly for SEO purposes. – Martin Alderson Jan 15 '13 at 13:51
If it helps, this is pretty much exactly what I want to achieve: wordpress.org/support/topic/… – Martin Alderson Jan 15 '13 at 14:34
hmmm I'm doubtful that this will be of any use SEO wise, especially since correct use of canonical urls in the head tags will mean that google will ignore these additional pages, that or it will penalise you for duplicated content – Tom J Nowell Jan 15 '13 at 14:56
Yeah, I know it is a bit of a cludge. All I want to do is wordpress to 'ignore' anything after the www.sitename.com/%category%/%postname% - so I can process it on page. – Martin Alderson Jan 15 '13 at 15:50
up vote 0 down vote accepted

You will need to whitelist a new query_var:

function add_query_vars($aVars) {
    $aVars[] = "subpage"; // represents the name of the product category as shown in the URL
    return $aVars;

// hook add_query_vars function into query_vars
add_filter('query_vars', 'add_query_vars');

You will need then need a rewrite rule to match your URL and pass in the correct query variables:


Finally on your pages template, you'll want to look for that query var, e.g.

if( !empty(get_query_var('subpage') )){ 
    // do subpage stuff
    $subpage = get_query_var('subpage');
    // process above value
} else { 
    // not on subpage, do normal page stuff 

Flush permalinks and you're good to go.

You should probably make good use of get_template_part, how you store the subpage data is up to you, post meta might work, just remember that it won't be searchable by default but there are other questions that can answer that problem

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.