1

There was a problem in which it was necessary to get permalink of the category/tag viewed. I have not found standard functions, everything other authors offered was only for categories.

I resoved the problem this way:

$url = get_term_link(
    $GLOBALS['wp_query']->queried_object->term_id,
    $GLOBALS['wp_query']->queried_object->taxonomy
);

Do you have more interesting solution?

1 Answer 1

1

get_queried_object will give you the current term object being viewed. You can pass that directly to get_term_link as the first argument.

$url = get_term_link( get_queried_object() );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.