WordPress.org

Ready to get started?Download WordPress

Forums

Category Icon Images Suggestions? (2 posts)

  1. pezastic
    Member
    Posted 9 years ago #

    I'm looking for a way to have an image in place of the first category of a multi-category post where the rest of the categories are displayed by text name. The image needs to link to that one category's archive. Any ideas?

  2. seriocomic
    Member
    Posted 9 years ago #

    I think this would present problems due to category weighting. Because the categories for the post are shown in ID order, so you may not have an image representing the category you want.

    Be that as it may, on solution (probably the worst compared to an external hack or a plugin) requires hacking the code of template-functions-category.php in wp-includes (at least on the 1.2.x versions).

    Starting around line 60 where the function the_category is set, set a counter variable outside the foreach loop, then do an if...then checking that it's the first category, and replicate the same code but change the link-text to an image tag using whatever code you want to generate it.

    There's probably a much tidier way of doing this but...

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.