Title: Help adding wp tag cloud
Last modified: August 18, 2016

---

# Help adding wp tag cloud

 *  Resolved [geekgirl](https://wordpress.org/support/users/geekgirl/)
 * (@geekgirl)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/help-adding-wp-tag-cloud/)
 * Hi everyone…
 * I am trying to add a tag cloud to my sidebar using the following code
 *     ```
       <?php if ( function_exists('wp_tag_cloud') ) : ?>
       <?php wp_tag_cloud('smallest=8&largest=22'); ?>
       </ul>
       </li>
       <?php endif; ?>
       ```
   
 * The cloud shows up but it’s causing validation errors with the “li” and “ul” 
   tags..I’ve tried playing around with it for days and can’t figure it out…Because
   I don’t understand the code. The following link shows my original sidebar code
   [http://wordpress.pastebin.ca/807114](http://wordpress.pastebin.ca/807114). I
   want to add the tag cloud under this code that is on line 52 `<h2 class="sidebartitle"
   ><img src="http://lovelatoya.com/wp-content/uploads/2007/11/cat.gif" alt="categories"/
   ></h2>`
    Could someone please tell me the correct way to do this so that my code
   will validate?

Viewing 8 replies - 1 through 8 (of 8 total)

 *  [richarduk](https://wordpress.org/support/users/richarduk/)
 * (@richarduk)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/help-adding-wp-tag-cloud/#post-663265)
 *     ```
       <?php if ( function_exists('wp_tag_cloud') ) : ?>
       <?php wp_tag_cloud('smallest=8&largest=22'); ?>
       <?php endif; ?>
       ```
   
 * No need for ul etc. as by default there are none.
 * If want ul etc. then use
 *     ```
       <?php if ( function_exists('wp_tag_cloud') ) : ?>
       <?php wp_tag_cloud('smallest=8&largest=22&format=list'); ?>
       <?php endif; ?>
       ```
   
 * Again, no need to manually add in ul li etc. Look in source code and see what’s
   been churned out, then use that to style it.
 * 🙂
 *  Thread Starter [geekgirl](https://wordpress.org/support/users/geekgirl/)
 * (@geekgirl)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/help-adding-wp-tag-cloud/#post-663361)
 * Thanks for your response…but that does not solve my issue. The problem is I don’t
   understand the “li” and “ul” tags very well…so when I add this code
 *     ```
       <?php if ( function_exists('wp_tag_cloud') ) : ?>
       <?php wp_tag_cloud('smallest=8&largest=22&format=list'); ?>
       <?php endif; ?>
       ```
   
 * to my sidebar…I get 8 validation errors concerning the “li” and “ul” tags which
   can be found here
    [http://validator.w3.org/check?uri=http%3A%2F%2Flovelatoya.com&charset=%28detect+automatically%29&doctype=Inline&group=0](http://validator.w3.org/check?uri=http%3A%2F%2Flovelatoya.com&charset=%28detect+automatically%29&doctype=Inline&group=0)
 * I know that the tag cloud code I’m adding is correct…I just don’t know how to
   add it to my existing code so that it will still validate. Any suggestions?
 *  Thread Starter [geekgirl](https://wordpress.org/support/users/geekgirl/)
 * (@geekgirl)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/help-adding-wp-tag-cloud/#post-663419)
 * anyone?
 *  [richarduk](https://wordpress.org/support/users/richarduk/)
 * (@richarduk)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/help-adding-wp-tag-cloud/#post-663432)
 * Have you taken the tag cloud out for good now? Can’t see it on that page, and
   the page validates.
 * Copy the relevant HTML and paste it here if you still want to get it to work.
 *  Thread Starter [geekgirl](https://wordpress.org/support/users/geekgirl/)
 * (@geekgirl)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/help-adding-wp-tag-cloud/#post-663433)
 * Yes I took the tag cloud out because I couldn’t figure it out. Now I have just
   added the following code back to my sidebar
 *     ```
       <?php if ( function_exists('wp_tag_cloud') ) : ?>
       <?php wp_tag_cloud('smallest=8&largest=22'); ?>
       <?php endif; ?>
       ```
   
 * and I am getting 2 validation errors.
 * [http://validator.w3.org/check?uri=http%3A%2F%2Flovelatoya.com&charset=%28detect+automatically%29&doctype=Inline&group=0](http://validator.w3.org/check?uri=http%3A%2F%2Flovelatoya.com&charset=%28detect+automatically%29&doctype=Inline&group=0)
   
   Here is my sidebar code now… [http://wordpress.pastebin.ca/809567](http://wordpress.pastebin.ca/809567)
 * Thanks for responding
 *  [richarduk](https://wordpress.org/support/users/richarduk/)
 * (@richarduk)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/help-adding-wp-tag-cloud/#post-663437)
 * What you have is this:
 *     ```
       <ul class="list-cat">
       <?php if ( function_exists('wp_tag_cloud') ) : ?>
       <?php wp_tag_cloud('smallest=8&largest=22'); ?>
       <?php endif; ?>
       </ul>
       </li>
       </ul>
       ```
   
 * What you need is this:
 *     ```
       <?php if ( function_exists('wp_tag_cloud') ) : ?>
       <?php wp_tag_cloud('smallest=8&largest=22'); ?>
       <?php endif; ?>
       ```
   
 * That will produce something like this:
 *     ```
       <a href='http://www.mysite.com/?tag=oranges' class='tag-link-14' title='1 topics' style='font-size: 8pt;'>oranges</a>
       <a href='http://www.mysite.com/?tag=plums' class='tag-link-7' title='2 topics' style='font-size: 15pt;'>plums</a>
       <a href='http://www.mysite.com/?tag=peaches' class='tag-link-8' title='3 topics' style='font-size: 22pt;'>peaches</a>
       ```
   
 * In other words, you don’t need
 *     ```
       <ul>
       <li> </li>
        </ul>
   
       If you DO want
       <ul>
       <li> </li>
        </ul>
       ```
   
 *  elements, it will be done automatically by using this:
 *     ```
       <?php if ( function_exists('wp_tag_cloud') ) : ?>
       <?php wp_tag_cloud('smallest=8&largest=22&format=list'); ?>
       <?php endif; ?>
       ```
   
 * Which will produce something like this:
 *     ```
       <ul class='wp-tag-cloud'>
       	<li><a href='http://www.mysite.com/?tag=oranges' class='tag-link-14' title='1 topics' style='font-size: 8pt;'>oranges</a></li>
       	<li><a href='http://www.mysite.com/?tag=plums' class='tag-link-7' title='2 topics' style='font-size: 15pt;'>plums</a></li>
       	<li><a href='http://www.mysite.com/?tag=peaches' class='tag-link-8' title='3 topics' style='font-size: 22pt;'>peaches</a></li>
       </ul>
       ```
   
 * Note that NO
 *     ```
       <ul> or
       <li>
       ```
   
 *  elements were added – WordPress did it automatically, producing an unordered
   list with a class of wp-tag-cloud which you can style from inside your style.
   css e.g. ul.wp-tag-cloud {font-style:normal;}
 * 🙂
 *  Thread Starter [geekgirl](https://wordpress.org/support/users/geekgirl/)
 * (@geekgirl)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/help-adding-wp-tag-cloud/#post-663445)
 * Ok, so I followed your advice and added
 *     ```
       <?php if ( function_exists('wp_tag_cloud') ) : ?>
       <?php wp_tag_cloud('smallest=8&largest=22'); ?>
       <?php endif; ?>
       ```
   
 * and now I have 6 more errors than I did before. Here is my sidebar code now. 
   Did i do something wrong?
    [http://wordpress.pastebin.ca/810622](http://wordpress.pastebin.ca/810622)
 *  Thread Starter [geekgirl](https://wordpress.org/support/users/geekgirl/)
 * (@geekgirl)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/help-adding-wp-tag-cloud/#post-663456)
 * Thank u so much Richard for all your help..It is valid now..The problem was that
   I needed to add the `</li></ul>` before adding the tag cloud code. Thank u again!

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Help adding wp tag cloud’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 8 replies
 * 2 participants
 * Last reply from: [geekgirl](https://wordpress.org/support/users/geekgirl/)
 * Last activity: [18 years, 6 months ago](https://wordpress.org/support/topic/help-adding-wp-tag-cloud/#post-663456)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
