I'm writing ajax handling for a theme. I'm trying to get term and taxonomy slugs from a link I click. The link is being passed with jQuery to PHP for further processing.
Let's say my custom taxonomy is "tax" and term within that taxonomy is "abc":
link I click looks like this -
It's being parsed with
wp_parse_url(). After parsing URL and fiddling with it a little I get "abc" as my term slug and "tax" as my taxonomy slug.
Then I use
get_term_by( 'slug', 'abc', 'tax' ) and get term data this way. Simple.
Problem occurs when taxonomy slug is rewritten.
Let's say I've rewritten my custom taxonomy slug "tax" with
'rewrite' => array( 'slug' => 'tax-rewrite' ), passed to
Now link I click looks like this:
When I pass it to
get_term_by() as "tax-rewrite" it fails because
get_term_by() needs original taxonomy slug which in this case is still "tax", but I can't get it from the link anymore.
Is there a way to get original taxonomy slug from rewritten link, get original taxonomy slug from rewrite slug, or any other way to get term data for my ajax handling?
Best regards, Dan.