(Revised answer)
So Let’s See The Issues With Your Rewrite Rule..
-
The first parameter passed to
add_rewrite_rule()
(which is the regular expression pattern) should not start withhome_url()
or any functions which outputs the website URL. So this is wrong:home_url() . '/car/([^/]*)/([^/]*)/?'
because the generated regular expression (RegEx) pattern would be:
http://example.com/car/([^/]*)/([^/]*)/?
which will never be matched, because the request (see
WP::$request
) never starts with the website URL. And it doesn’t even start with/
. -
Is the
&model=$matches[1]
part a typo?index.php?taxonomy=car&term=$matches[1]&model=$matches[1]&trim=$matches[2]
Now The Fixes
-
The
home_url() . '/car/([^/]*)/([^/]*)/?'
should be (no trailing/
at the start):'^car/([^/]*)/([^/]*)/?'
-
The
index.php?taxonomy=car&term=$matches[1]&model=$matches[1]&trim=$matches[2]
should probably be without the&model=$matches[1]
:index.php?taxonomy=car&term=$matches[1]&trim=$matches[2]
However, even with that
&model=$matches[1]
, the rule actually worked in my case. -
And not sure if you’ve already added this somewhere in your code, but I’d add it so that I could get the value of the “trim” parameter in the URL:
add_rewrite_tag( '%trim%', '([^/]+)' );
You’d add that before/after the
add_rewrite_rule()
line, and to get the “trim” value, you could useget_query_var( 'trim' )
.