Пример #1
0
function get_referrer_category()
{
    global $posts;
    if (!($referrer_url = get_referrer_url(false))) {
        return false;
    }
    foreach (get_the_category($posts[0]->ID) as $cat) {
        $cat_link = get_category_link($cat->term_id);
        if (false !== strpos($referrer_url, $cat_link)) {
            return $cat;
        }
    }
    return false;
}
function get_referrer_term($taxonomy = 'category')
{
    global $posts;
    if (!($referrer_url = get_referrer_url(false))) {
        return false;
    }
    foreach (get_the_terms($posts[0]->ID, $taxonomy) as $term) {
        $term_link = get_term_link($term->term_id, $taxonomy);
        if (false !== strpos($referrer_url, $term_link)) {
            return $term;
        }
    }
    return false;
}