[wp-hackers] wp-rewrite

DD32 wordpress at dd32.id.au
Tue Feb 5 10:08:56 GMT 2008

I've come up with this version:

add_action('generate_rewrite_rules', 'tp_add_rewrite_rules');
function tp_add_rewrite_rules( $wp_rewrite ) {
    $new_rules = array( "(custom_page_name)" => 'index.php?tp=' . $wp_rewrite->preg_index(1));
    $wp_rewrite->rules = $wp_rewrite->rules + $new_rules;

And either of these:

add_filter('request', 'tp_request');
function tp_request($r){
	if( isset($r['tp']) && isset($_GET['hash']) )
		$r['name'] = $_GET['hash'];
	return $r;
add_action('parse_request', 'tp_request');
function tp_request($wp){
	switch( $wp->request) {
		case 'custom_page_name':
			if( isset($_GET['hash']) )
				$wp->query_vars['name'] = $_GET['hash'];

It works as expected.. And am starting to think i was dreaming that my other method worked :P
I'll be using a few request lists hardcoded, so, probably use the 2nd method.

On Tue, 05 Feb 2008 19:34:03 +1100, DD32 <wordpress at dd32.id.au> wrote:

More information about the wp-hackers mailing list