Forums

[Plugin: Simple Tags] Limit tag cloud to only ONE category (1 post)

  1. cablejp
    Member
    Posted 3 years ago #

    How is it possible to restrain the tag cloud to tags from only one category? On Amaury's site, I saw the code for the opposite, i.e. the code to display all tags EXCEPT the ones from a given category:

    <?php

    // ID de la catégorie
    $category_id = 3;

    // On récupérer les ID des articles
    $post_ids = get_objects_in_term( $category_id, 'category' );

    // On récupérer les ID des tags liés à ces articles
    $tag_ids = wp_get_object_terms( (array) $post_ids, 'post_tag', array('fields' => 'ids') );

    // On passe le tableau des tags dans une chaine de caractère séparé de ","
    $tag_param = '';
    if ( ! empty($tag_ids) ) {
    $tag_param = 'exclude=' . implode(',', (array) $tag_ids );
    }

    // On utilise Simple Tags - Nuage de tags
    st_tag_cloud('number=100&'.$tag_param);

    ?>

    Now, how to do the opposite? I tried replacing the "exclude=" by "include=", but to no avail (all tags from all categories get displayed).

Topic Closed

This topic has been closed to new replies.

About this Topic