• Hi,

    Is there a pluging or does someone have code to get the option to set a CSS class for widgets?

    For example in the admin panel i add widgets and i want there a custom field to add some css code to make the widgets background red and another widget blue.

    i’ve search but couldn’t find such thing.

    anyone?

    thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter arjanver

    (@arjanver)

    that is not what i mean.

    For example in the admin panel i add widgets and i want there a custom field to add some css code to make the widgets background red and another widget blue.

    so i define some background classes in the template css file.
    and i want a option to choose from the admin area to set the class.
    So i can easy change the background color for different sidebar boxes.

    If you inspect the code generated by those widgets using a tool like Firebug, you will see that they are already being assigned unique CSS classes. For example, the div for the default Pages widget gets a class called “widget_pages”. Just use the existing classes along with descendant selectors to style the widgets.

    Thread Starter arjanver

    (@arjanver)

    no offence but you didn’t understand my question ??

    i know i can predefine these id’s/classes, but that is not what i want.

    i want to change the background color of a widget from the widgets admin panel.

    Why would you want to do that?

    To answer your question, no, it is not possible without rewriting the PHP code of the widgets. The code for the default widgets is in this file:

    /wp-includes/default-widgets.php

    Of course, hacking the core files is highly inadvisable, since all your hacks will be lost whenever you upgrade to a new WP version. What you should do instead is create custom widgets based on the default widget code, and then install them as plugins — if you really want to take it that far. Personally, I think it would be much easier to style the widgets by editing the CSS file.

    Did you ever solve this? I want to do the same thing, got a lot of widget areas in the back end that I’d like to colour code for the client.

    Thread Starter arjanver

    (@arjanver)

    no, sorry

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Set CSS attribute for widgets’ is closed to new replies.