$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>custom taxonomy - How to add a Rewrite RuleCategory Structure|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

custom taxonomy - How to add a Rewrite RuleCategory Structure

matteradmin9PV0评论

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');
Post a comment

comment list (0)

  1. No comments so far