WordPress.org

Ready to get started?Download WordPress

Forums

Add an image to category (3 posts)

  1. bondigor69
    Member
    Posted 1 year ago #

    Hey guys I would like to get help.
    What I want to accomplish is

    1-Be able to set an image for each category
    2-Display Children categories of an category(IF HAS SOME) with this image.

    So if I have My main category ---Cars
    -----------------------------------Mercedes
    -----------------------------------Honda
    -----------------------------------Exotic Cars
    --------------------------------------Lambo
    --------------------------------------Ferrari

    Set an image for each category.
    So if I navigate to "Cars" I'll see Mercedes, Honda & Exotic Cars with their thumbnails.

    Now If I navigate to Honda, there is no children category so I would like to display any categories in Cars if Possible.

    Thank you for help

  2. bcworkz
    Member
    Posted 1 year ago #

    There's a number of approaches. Regardless, the template needs to be modified to insert an image into the usual category link. The question is, where to store the relationship between category and image?

    You could even create a new table, but it could also be done as a taxonomy. One other thought I had was to use the description field of the category, assuming your theme doesn't use it. Then you don't need any special code to manage the relationship, just paste the image url into existing the description field.

    Or you could simply name your images after the category, so that your template code can easily construct an image url.

  3. websitejunction
    Member
    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Topic