Return to Snippet

Revision: 26759
at May 10, 2010 06:39 by iroybot


Initial Code
add_action('init', 'flush_the_rewrite_rules');
add_filter('generate_rewrite_rules', 'create_rewrite_rules');
add_filter('query_vars', 'add_query_vars');

function create_rewrite_rules() {
	$variable='download';
	add_rewrite_rule($wordpress_root.'/'.$variable.'(/(.*))?/?$', 'index.php?pagename=$matches[1]&'.$variable.'=$matches[3]');
}

function flush_the_rewrite_rules () {
	flush_rewrite_rules;
}

function add_query_vars($public_query_vars) {
	$public_query_vars[] = 'download';
	return $public_query_vars;
}

Initial URL
http://wordpress.org/support/topic/194206

Initial Description
courtesy of mark8barnes (http://wordpress.org/support/profile/52354)

Initial Title
Adding Rules to the WordPress WP_Rewrite

Initial Tags
php, wordpress, api

Initial Language
PHP