custom prefix to base using generate_rewrite_rules not working
-
Currently someone goes to:
site.com/category/name/page/2/
To get a list of items in that category.
I’m trying to make that:
site.com/grid/category/name/page/2/
So caching works properly and I can display using a different template in my archive file.I made a tiny plugin using the generate_rewrite_rules filter.
It modifies it like so:public function filterRewriteRules( $wp_rewrite ) { foreach ($wp_rewrite->rules as $key => $value) { if (preg_match('/^[\(]?(category|author|date|tag)/',$key)) { $wp_rewrite->rules['grid/'.$key] = $value; } } print_r($wp_rewrite->rules); }
That appears to be working. It adds duplicate rules to the array:
[grid/(category)/trackback/?$] => index.php?pagename=$matches[1]&tb=1 [grid/(category)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?pagename=$matches[1]&feed=$matches[2] [grid/(category)/(feed|rdf|rss|rss2|atom)/?$] => index.php?pagename=$matches[1]&feed=$matches[2] [grid/(category)/page/?([0-9]{1,})/?$] => index.php?pagename=$matches[1]&paged=$matches[2] [grid/(category)/comment-page-([0-9]{1,})/?$] => index.php?pagename=$matches[1]&cpage=$matches[2] [grid/(category)(/[0-9]+)?/?$] => index.php?pagename=$matches[1]&page=$matches[2] [grid/category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2] [grid/category/(.+?)/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2] [grid/category/(.+?)/page/?([0-9]{1,})/?$] => index.php?category_name=$matches[1]&paged=$matches[2] [grid/category/(.+?)/?$] => index.php?category_name=$matches[1]
But it doesn’t seem to work… ??
What am I missing here?
I’m using a custom setting on the permalink page:
/%category%/%post_id%/%postname%/
Not sure if that affects it.I also want to set another filter so if they are on /grid/ anything it will add “grid” to all the links to category/author/date/tag on the page. Not certain what filter to use there.
I need a new url because super cache will cache the page, and it will stay static to either list or grid from then on for everyone else since it’s cached.
- The topic ‘custom prefix to base using generate_rewrite_rules not working’ is closed to new replies.