• Hi,

    Can you please tell me how to show only SELECT Tags in Tag cloud in Sidebar Widget.

    I want to show only the primary tags in sidebar and want to hide all others. So that it appear on each blogposts only and wont crowd in sidebar.

    If you check http://www.minterest.com/ then it shows all the tags in sidebar and its crowded.. so I thought it would be nice if I show only select tags as others will be visible when you go to a single post.

    Thanks!

Viewing 15 replies - 1 through 15 (of 16 total)
  • Thread Starter Mahesh Mohan

    (@maheshone)

    Tell me how to do that without using any plugins..

    http://www.transformationpowertools.com/wordpress/edit-widget-parameters-filter-wordpress
    http://codex.wordpress.org/Function_Reference/wp_get_post_tags

    add this to functions.php of your theme:

    add_filter('widget_tag_cloud_args','single_post_tag_cloud_tags');
    function single_post_tag_cloud_tags($args) {
    if( is_single() ) {
    global $post;
    $post_tag_ids = wp_get_post_tags( $post->ID, array( 'fields' => 'ids' ) );
    $args = array('include' => implode(',',$post_tag_ids));
    }
    return $args; }
    Thread Starter Mahesh Mohan

    (@maheshone)

    Hey, I want to add the Tag Cloud to Sidebar by showing only SELECT Tags and not all.

    Hey, I want to add the Tag Cloud to Sidebar… choosing the ID of tags.

    ?

    – are you using the default tag cloud widget?
    – do you want to show only the tags of the current post in the sidebar?

    if yes to both, then the suggested code should work for you.

    if you want to select the tags in a different way, please post more details.

    or consider using a plugin – http://wordpress.org/extend/plugins/search.php?q=tag+cloud+widget&sort=

    Thread Starter Mahesh Mohan

    (@maheshone)

    Hi..

    Please check out http://www.minterest.com/ you can see my Tag Cloud there in sidebar (2nd last widget)…

    But its showing all the tags I have added to my blog.. Now what I want is show only select tags there…. so that widget appears on all Pages…

    Got it?

    one possibility:
    for a fixed sub-set of tags, try to add this to functions.php of your theme:
    (you will need to use the tag IDs to build the list)

    add_filter('widget_tag_cloud_args','selected_tags_tag_cloud);
    function selected_tags_tag_cloud($args) {
    $args = array('include' => '3,7,45,75,123');
    return $args; }
    Thread Starter Mahesh Mohan

    (@maheshone)

    Okay. Where should I paste this code?

    My functions.php file code is

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Thread Starter Mahesh Mohan

    (@maheshone)

    Hi,

    I got the idea.. Can you please tell me how to modify this… to select the tags required..

    <?php wp_tag_cloud(”); ?>

    How to add filters to this?

    Where should I paste this code?

    anywhere after the first <?php and before the last ?> without breaking any existing functions.

    http://codex.wordpress.org/Functions_File_Explained

    Thread Starter Mahesh Mohan

    (@maheshone)

    No. Please check the previous question… I got another alternative..

    My Theme shows tag cloud by default for empty lower sidebar widget.. so I can modify the Sidebar Template

    Where I see the code

    <?php wp_tag_cloud(”); ?>

    So tell me how to filter this…. πŸ™‚

    Thread Starter Mahesh Mohan

    (@maheshone)

    Am checking http://codex.wordpress.org/Function_Reference/wp_tag_cloud now about how to filter…

    Thread Starter Mahesh Mohan

    (@maheshone)

    Thank you so much… I got it….

    I replaced that code with <?php wp_tag_cloud(‘include=10,27’); ?>

    So its showing only 2 tags now… Now need to find the IDs of all the tags required…

    Thanks once again! πŸ™‚

    Thread Starter Mahesh Mohan

    (@maheshone)

    Okay. By the way how to add multiple parameters? I want to display all the tags in same size irrespective of the number of posts filed under that tag.

    In that case what should I do to:

    <?php wp_tag_cloud(‘include=10,27’); ?>

    try:
    (adjust the font size)

    <?php wp_tag_cloud('include=10,27&smallest=12&largest=12'); ?>

    about how to filter…

    you only need to filter, if you are using the tag cloud widget
    – in your case you seem to be working with the wp_tag_cloud() code directly in sidebar.php (?) and you need to add the right parameters/arguments to the function.

    Thread Starter Mahesh Mohan

    (@maheshone)

    Oh yeah…

    Its working….

    <?php wp_tag_cloud(‘include=10,27&smallest=12&largest=12’); ?>

    Now how to add more spaces between tags so that one can read more easily?

    Check out the tag cloud now… http://www.minterest.com/sitemap/ (the last sidebar widget)

    What’s the best way to separate tags? Now it looks like a single sentence rather than tags.

    Whats the use of parameter “Separator”?

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘How To Show Select Tags in Tag Cloud’ is closed to new replies.