[resolved] Class for the tag cloud widget (6 posts)

  1. jdarias
    Posted 5 years ago #

    I would like to change the margin of the div that contains the tag cloud in my tag cloud widget.
    the tag cloud widget markup looks like this:

    <li class="widget">
    	<h4>widget title</h4>
    		the tags are here

    The problem with this markup is the div that contains the tags, wich has no id or class for me to point css at it!
    I have to create a general css rule for it and then specify other rules to correct all of the other widgets. So how can i have a class for this specific tags div?

  2. esmi
    Forum Moderator
    Posted 5 years ago #

    You need to edit the theme's functions.php so that it adds appropriate classes & ids to each of your widgets.


  3. jdarias
    Posted 5 years ago #

    I´m already registering the sidebar widgets, i´m putting li class="widget" and /li to each widget, and the title goes with h4 tags. The problem is just with the tag cloud widget, specifically with the div it uses to contain the tags. As it is generated by the widget, it comes with no class, wich is a bit of a problem

  4. Michael
    Forum Moderator
    Posted 5 years ago #


    check particular this line:
    'before_widget' => '<li id="%1$s" class="widget %2$s">',

    this %2$s will generate a distinct class for each widget.

  5. jdarias
    Posted 5 years ago #

    Thanks Alchymyth! Didn´t know those expressions could generate that! Too bad it´s not clearly mentioned in the codex! (or maybe i´m overseeing it).
    That got my issue fixed!

  6. sparajurij
    Posted 4 years ago #

    Very useful, but I have a question: how can i get the exact class of the tag cloud and put it in my css?

Topic Closed

This topic has been closed to new replies.

About this Topic