WordPress.org

Forums

[resolved] Display tags which have no posts (5 posts)

  1. mjdobson
    Member
    Posted 2 years ago #

    WordPress newbie here! I've been working on a personal resume/blog site (michaeljdobson.com) and I've been looking for a way to display all of my technical skills/interests on the home page using tags. To elaborate, I want a list of my technical skills, but I also want that list to link to all relevant blog or project pages which have been tagged with that topic using a tag cloud.

    The problem is there are many skills I want listed but which haven't been used in any posts. Some of these tags I may never end up using, but I still want them there. Currently I have a temporary post which is tagged by all of these, but I'm wondering if there is some way to force all tags to be shown.

  2. alchymyth
    Forum Moderator
    Posted 2 years ago #

    you can add some parameter to the tag cloud using a filter function:

    example:

    add_filter('widget_tag_cloud_args','show_zero_count_tag_cloud_tags');
    function show_zero_count_tag_cloud_tags($args) {
    $args = array('hide_empty' => false);
    return $args;
    }

    although 'hide_empty' is not documented with wp_tag_cloud(), it seems to work because the paramters are passed through to the internally used get_terms() function.
    http://codex.wordpress.org/Function_Reference/wp_tag_cloud
    http://codex.wordpress.org/Function_Reference/get_terms

    because the tag cloud shows only 45 tags by default, you might need to expand the one line to:

    $args = array('hide_empty' => false, 'number' => 100);
  3. mjdobson
    Member
    Posted 2 years ago #

    Thanks for the prompt response. I should have mentioned that although I have programming experience I've never used PHP. Where can I find hide_empty or should I be adding this code to somewhere like functions.php?

    Additionally if I were to opt for using a more configurable tag cloud plugin, like Ultimate Tag Cloud would it be further complicated?

  4. alchymyth
    Forum Moderator
    Posted 2 years ago #

    I keep forgetting to mention that the filter function needs to be added to functions.php of the theme.

    Additionally if I were to opt for using a more configurable tag cloud plugin, like Ultimate Tag Cloud would it be further complicated?

    no idea - this will depend on how the plugin is coded.

    the quoted plugin for instance does not use the 'widget_tag_cloud_args' filter, so the filter would simply have no effect.

  5. mjdobson
    Member
    Posted 2 years ago #

    Got it working. Thank you very much!

Topic Closed

This topic has been closed to new replies.

About this Topic