Forums

Customizing widget class names (2 posts)

  1. dfunkydog
    Member
    Posted 2 years ago #

    I have a widgetized footer and I want to be able to style every third widget in the footer differently. I know I can use :nth-child(3n) in css but that won't work in older browsers. Currently I'm using jquery to solve this.

    However I am after a non-javascript solution, specifically getting the widgets to output class names based on their position, widget-1, widget-2 etc.

    Is this possible?

  2. s_ha_dum (was apljdi)
    Member
    Posted 2 years ago #

    $s = wp_get_sidebars_widgets();
        print_r($s);

    That should give you an array of sidebars and their widgets. I haven't checked carefully but it looks like the widgets are in order so you should be able to parse that to find you widget positions.

    print_r($args);

    ... will tell you which sidebar your widget is in, if you need that.

Topic Closed

This topic has been closed to new replies.

About this Topic