wp_generate_tag_cloud example

foreach ( (array) $api_tags as $tag ) {
            $url                  = self_admin_url( 'plugin-install.php?tab=search&type=tag&s=' . urlencode( $tag['name'] ) );
            $data                 = array(
                'link'  => esc_url( $url ),
                'name'  => $tag['name'],
                'slug'  => $tag['slug'],
                'id'    => sanitize_title_with_dashes( $tag['name'] ),
                'count' => $tag['count'],
            );
            $tags[ $tag['name'] ] = (object) $data;
        }
        echo wp_generate_tag_cloud(
            $tags,
            array(
                /* translators: %s: Number of plugins. */
                'single_text'   => __( '%s plugin' ),
                /* translators: %s: Number of plugins. */
                'multiple_text' => __( '%s plugins' ),
            )
        );
    }
    echo '</p><br class="clear" /></div>';
}



        if ( is_wp_error( $link ) ) {
            return;
        }

        $tags[ $key ]->link = $link;
        $tags[ $key ]->id   = $tag->term_id;
    }

    // Here's where those top tags get sorted according to $args.     $return = wp_generate_tag_cloud( $tags$args );

    /** * Filters the tag cloud output. * * @since 2.3.0 * * @param string|string[] $return Tag cloud as a string or an array, depending on 'format' argument. * @param array $args An array of tag cloud arguments. See wp_tag_cloud() * for information on accepted arguments. */
    $return = apply_filters( 'wp_tag_cloud', $return$args );

    
if ( is_wp_error( $tags ) ) {
        wp_die( $tags->get_error_message() );
    }

    foreach ( $tags as $key => $tag ) {
        $tags[ $key ]->link = '#';
        $tags[ $key ]->id   = $tag->term_id;
    }

    // We need raw tag names here, so don't filter the output.     $return = wp_generate_tag_cloud(
        $tags,
        array(
            'filter' => 0,
            'format' => 'list',
        )
    );

    if ( empty( $return ) ) {
        wp_die( 0 );
    }

    
Home | Imprint | This part of the site doesn't use cookies.