• Resolved ransom1337

    (@ransom1337)


    Does anyone know where I can edit the HTML of the Category sidebar widget, please? I can’t find it in my theme anywhere.

    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • the only way to influence the output of the default widgets is per filter function;

    what exactly do you want to edit, or what are you trying to achieve?

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    That’s a built in widget and you should not edit that (it’s a file that ships with WordPress).

    Try installing category widget plugin and use that instead.

    http://wordpress.org/extend/plugins/search.php?q=category+widget

    Or if it’s just CSS that you want to modify then you can modify that via a child theme or a custom CSS plugin.

    Edit: Or as alchymyth said, the widget output may be filterable.

    Thread Starter ransom1337

    (@ransom1337)

    I’m just trying to put an icon next to each category name, because each of my categories will have different icons associated with them. I thought I’d put PHP into the CSS and do it as a background-image, but that’d mean changing my CSS files to style.php and I’m not sure how badly that’ll mess with WordPress.

    So I thought I’d just get into the HTML and add an img tag there.

    I’ve just tried adding the Almost All Categories Widget but it seems to source its code from the same place as the built-in widget anyway so it’s not much of a different outcome for me.

    Can either of you (or anyone) suggest the best way of doing this please?

    Thanks for your replies.

    that’d mean changing my CSS files to style.php and I’m not sure how badly that’ll mess with WordPress.

    A few years back I managed to get an @import ‘../style.php’ working inside style.css. As far as I remember; WordPress didn’t mind.

    Did you try using simple CSS?
    For example:

    li.cat-item-12 {background: url(image.jpg); padding-left: 20px;)

    this will work for category with ID=12.

    This solution is ok only if you have a set of predefined categories.
    If you would like dynamic attachment of images (set an icon when you add a a new category) then probably you need to make a plugin.

    Thread Starter ransom1337

    (@ransom1337)

    Ah yeah I was going to try to be smart about it and use PHP to get the category ID dynamically, but I guess just styling the specific ID won’t be too much trouble. There’s only a few categories anyway.

    I’ll do that. Thanks for your suggestions, everyone!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Where can I edit the HTML of the Category sidebar widget?’ is closed to new replies.