hook and rewrite
-
hi,
everybody knows that if you write http://www.domain.com/category/categoryname you arrive on /wp-content/theme/template/archive.php with a variable with the category name.i’d like to do the same. i want to write http://www.domain.com/list/variable1/variable2/variable3/etc and arrive to /wp-content/theme/template/list.php file.
i wrote the code below but i can not go on…
the code add a rewrite rule, but i arrive to /wp-content/theme/template/index.php…can someone help me?
thanks in advance
manueladd_action('generate_rewrite_rules', 'add_rewrite_rules'); add_filter('query_vars', 'query_vars'); add_filter('init','flushRules'); function add_rewrite_rules( $wp_rewrite ) { $new_rules = array('list/(.+?)/?$' => 'index.php?list=$matches[1]'); $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; } function query_vars($public_query_vars) { $public_query_vars[] = "list"; return $public_query_vars; } function flushRules(){ global $wp_rewrite; $wp_rewrite->flush_rules(); }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘hook and rewrite’ is closed to new replies.