custom taxonomy - How to add a Rewrite RuleCategory Structure

admin2025-06-03  2

I'm currently trying to use add_rewrite_rule() to create a rewrite (duh!), for a custom taxonomy page.

I've added the rewrite tag "sort" with the following code:

add_rewrite_tag('%sort%','([^&]+)');

The issue is I'm not very familiar with the rewrite structure and I'm struggling.. I have a rewrite rule that is getting close, but still not quite working.

add_rewrite_rule('^vehicle-make/([^/]*)/?','index.php?page_id=40&sort=$matches[1]','top');

The problem is it's pulling in the wrong page; I'm needing to show the taxonomy archive for the specific term. So instead of a page ID I'm guessing I just need to pull in the taxonomy name and current term archive.

I'm currently trying to use add_rewrite_rule() to create a rewrite (duh!), for a custom taxonomy page.

I've added the rewrite tag "sort" with the following code:

add_rewrite_tag('%sort%','([^&]+)');

The issue is I'm not very familiar with the rewrite structure and I'm struggling.. I have a rewrite rule that is getting close, but still not quite working.

add_rewrite_rule('^vehicle-make/([^/]*)/?','index.php?page_id=40&sort=$matches[1]','top');

The problem is it's pulling in the wrong page; I'm needing to show the taxonomy archive for the specific term. So instead of a page ID I'm guessing I just need to pull in the taxonomy name and current term archive.

Share Improve this question asked May 23, 2014 at 16:04 Austin BiggsAustin Biggs 3843 silver badges19 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

I found the correct url and patched the rewrite and it works perfectly now! This is what I ended with!

add_rewrite_rule('^vehicle-make/([^/]*)/([^/]*)/?','index.php?vehicle-make=$matches[1]&sort=$matches[2]','top');
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748939223a314993.html

最新回复(0)