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":
Example:
link I click looks like this - https://localhost/test/tax/abc/
.
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.
Example 2:
Let's say I've rewritten my custom taxonomy slug "tax" with 'rewrite' => array( 'slug' => 'tax-rewrite' )
, passed to register_taxonomy()
.
Now link I click looks like this: https://localhost/test/tax-rewrite/abc/
.
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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745177438a4615260.html
评论列表(0条)