[wp-hackers] Permalinkg Rule

Mike Schinkel mikeschinkel at newclarity.net
Mon Jun 7 08:11:36 UTC 2010

Hi Giro,

> Is possible to define a rule, that if I have many pages
> /contributors/john
> /contributors/jack
> Where last name is always different but I want that all refer to same page,
> with a possibilitie to take name as parameter.
> Where I have to start looking ?

URL routing in WordPress can be a real challenge. I've been studying it for well over a year and I still struggle with it so the way I'm going to suggest may not be the best way, but it works for me (modify the function names to suit your preferences.):

===[Add this somewhere in your page.php template, or other page template]========

<?php echo get_person_slug(); ?>

===[Add this to your theme's functions.php]========


function my_query_vars($query_vars) {
	$query_vars[] = 'person_slug';
	return $query_vars;
function my_request($request) {
	if (isset($request['pagename'])) {	// "pagename" assumes that there is post_type of "page"  called "contributors", i.e. that you've added a page with a slug of "contributors." 
		$parts = explode('/',$request['pagename']);
		if ($parts[0]=='contributors') {
			$request['pagename'] = $parts[0];
			$request['person_slug'] = $parts[1];
	return $request;
function get_person_slug() {
	global $wp;
	return $wp->query_vars['person_slug'];



More information about the wp-hackers mailing list