WordPress.org

Ready to get started?Download WordPress

Ideas

default "Tag Cloud widget" allows excluding tags from cloud (widgets.php)

  1. strangeqargo
    Member

    like this

    function wp_widget_tag_cloud($args) {
    extract($args);
    $options = get_option('widget_tag_cloud');
    $title = empty($options['title']) ? __('Tags') : $options['title'];
    $extags = $options['extags'];
    echo $before_widget;
    echo $before_title . $title . $after_title;
    wp_tag_cloud("exclude=$extags");
    echo $after_widget;
    }

    function wp_widget_tag_cloud_control() {
    $options = $newoptions = get_option('widget_tag_cloud');

    if ( $_POST['tag-cloud-submit'] ) {
    $newoptions['title'] = strip_tags(stripslashes($_POST['tag-cloud-title']));
    $newoptions['extags'] = strip_tags(stripslashes($_POST['tag-cloud-extags']));
    }

    if ( $options != $newoptions ) {
    $options = $newoptions;
    update_option('widget_tag_cloud', $options);
    }

    $title = attribute_escape( $options['title'] );
    $extags = attribute_escape( $options['extags'] );
    ?>
    <p><label for="tag-cloud-title">
    <?php _e('Title:') ?> <input type="text" class="widefat" id="tag-cloud-title" name="tag-cloud-title" value="<?php echo $title ?>" /></label>
    </p>
    <p><label for="tag-cloud-extags">
    <?php _e('Exclude tags:') ?> <input type="text" class="widefat" id="tag-cloud-extags" name="tag-cloud-extags" value="<?php echo $extags ?>" /></label>
    </p>
    <input type="hidden" name="tag-cloud-submit" id="tag-cloud-submit" value="1" />
    <?php
    }

    tried it, it works

    Posted: 5 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.

  • Rating

    12345
    3 Votes
  • Status

    This is plugin territory

No tags yet.