Support » Plugins » wp_rewrite help

  • Resolved camdagr8


    I’m not too familiar with wp_rewrite and need some help creating a simple rewrite. I’ve looked at the codex and it’s very limited on rewrite help for doing something simple.

    I want to take the url:

    and rewrite it to:
    The catch is that I want the url all the way up to /chp in tact so that no matter what comes before /chp/ it’s used in the new url and the vars are added in.

    I have my permalinks set to the following:

    I’m trying the current rewrite:

    // URL rewrite
    // flush rules
    function wpngfb_flush() {
    	global $wp_rewrite;
    // Add a new rule
    function wpngfb_rules($rules) {
    	$newrules = array();
    	$newrules['^(.*)/chp/([0-9]+)$'] = 'index.php?pagename=$matches[1]&chp=$matches[2]';
    	return $newrules + $rules;
    // Add the chp var so that WP recognizes it
    function wpngfb_var_insert($vars) {
    	array_push($vars, 'chp');
    	return $vars;

    This works some what, but it’s dropping the /chp/1 from the url completely and ignoring the var include

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wp_rewrite help’ is closed to new replies.