WordPress.org

Forums

[resolved] Where can I edit the HTML of the Category sidebar widget? (7 posts)

  1. ransom1337
    Member
    Posted 2 years ago #

    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!

  2. alchymyth
    Forum Moderator
    Posted 2 years ago #

    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?

  3. 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.

  4. ransom1337
    Member
    Posted 2 years ago #

    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.

  5. Shane Gowland
    Member
    Posted 2 years ago #

    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.

  6. webily
    Member
    Posted 2 years ago #

    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.

  7. ransom1337
    Member
    Posted 2 years ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.