• Hello All,

    I read this topic (http://wordpress.org/support/topic/get-tags-specific-to-category) about to get the tags specific to a category.

    I am almost there but cannot figure out how to dynamically get the category ID when you are on the page as opposed to have to specify the category IDs when you call the function which actually means that you get all the tags from all the specified categories – I have italicized and bolded up in the snippet below where you have to specify the category IDs.

    <?php
    // Category tag function

    $args = array(
    ‘categories’ => ‘5,13,14’
    );
    $tags = get_category_tags($args);
    $content .= “<div>”;
    foreach ($tags as $tag) {
    $content .= “<span>tag_link\”>$tag->tag_name</span>”;
    }
    $content .= “</div>”;
    echo $content;
    ?>

    Thank you for your help!
    P

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Pierrick

    (@artpie)

    Hello All,

    Can anyone shed some light on the issue above. I am stuck…
    CHeers

    P

    how to dynamically get the category ID when you are on the page

    are you talking about the category archive page?

    if so, then the category id would be:

    get_query_var('cat')

    i.e. try:

    $args = array(
    'categories' => get_query_var('cat')
    Thread Starter Pierrick

    (@artpie)

    Thanks Alchymyth, it did the trick!

    But when I click on these tags within a category page, it would show me all posts with that tag as opposed to only the posts from that specific category… Do you know how to sort that out?

    Example here – http://www.relequalsatypical.co.uk/category/sam/

    Thanks again!
    P

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Display tags coming from a category’ is closed to new replies.