The MU forums have moved to

Finding a way to count active widgets (2 posts)

  1. hippo1010
    Posted 14 years ago #

    Hello. I'm fairly new to WP and I'm trying to find a way to have my widgets in my sidebar to have their own div.

    In my functions.php, in the line

    'before_widget' => '<div id="%2$s">',

    I want to be able to assign a number other than %2$s. I don't know if this is possible but I want to count how many active widgets are. Based on that number I then want to create a loop to assign a <div id="feature".$i> on that line so each widget has a div identified with a different number. I apply a different css format to each widget.

    Is there a variable, constant, function or something for that? I need a number and not just the name of the widget as unique identifier. The reason for that is that I need the css format to appear in a specific order, and widgets can be displayed in any order, which is why I can't use "%2$s".

    Any help will be greatly appreciated.

  2. magi182
    Posted 14 years ago #

    I'd be interested in this too -- if anyone know a solution. For me, it would even be enough to apply a class to every third, or every fourth widget.

About this Topic

  • Started 14 years ago by hippo1010
  • Latest reply from magi182