[wp-hackers] 2 Questions: $_REQUEST equivalent and using GET in mod_rewrite

Alex Andrews awgandrews at gmail.com
Wed Aug 29 19:00:39 GMT 2007


On 29/08/2007, DD32 <wordpress at dd32.id.au> wrote:
> > How can I get /artists/x/ to translate to artists.php?id=x or whatever.
> By the sounds of it, you've developed the standalone app not quite how
> you'd write a WP plugin.

Now I am cooking on gas. Decided to make a swish template loader to
intergate the previously existing script. But there is a further
mod_rewrite problem.

Here is the current function:

add_action('generate_rewrite_rules', 'ribcage_add_rewrite_rules');
function ribcage_add_rewrite_rules( $wp_rewrite ) {
	$new_rules = array(
		"(artists)/(.*)" => 'index.php?ribcage=1&artist_slug=' .
$wp_rewrite->preg_index(2),
		"(artists)" => 'index.php?ribcage=1&artist_index=1'
	);

	$wp_rewrite->rules = $wp_rewrite->rules + $new_rules;
}

Now this obviously passes like this
/artists/mrdave
And that works fine. But how about if one wants to pass more than one
variable. For example:
/artists/mrdave/bio
or
artist/mrdave/myrecord

where my record is the name of a record or whatever. Or whatever. I
presume this has something to do with preg_index();? Perhaps.

Thanks for your continued assistance.

Thanks again

Alex


More information about the wp-hackers mailing list