Support » Plugins » Hacks » Custom rewrite rules aren't working

  • I had some custom code (which didn’t work) then cycled through the Codex examples (which didn’t work) and now I’m wondering what I’m doing wrong. The code I originally used worked properly on a different site, but it wasn’t translating. In any case, here’s what I have now.

    // Remember to flush_rules() when adding rules
    function flushRules(){
    	global $wp_rewrite;
    // Adding a new rule
    function wp_insertMyRewriteRules($rules)
    	$newrules = array();
    	$newrules['(project)/(\d*)$'] = 'index.php?pagename=$matches[1]&id=$matches[2]';
    	return $newrules + $rules;
    // Adding the id var so that WP recognizes it
    function wp_insertMyRewriteQueryVars($vars)
        array_push($vars, 'id');
        return $vars;

    There is no “id” elemt in the wp_query array. I’ve reset my permalinks, logged in, logged out, refreshed, cleared cache, etc etc. Something’s not right. So…Where am I going wrong?

  • The topic ‘Custom rewrite rules aren't working’ is closed to new replies.