The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

how to display subcategory images in main category (5 posts)

  1. omidgs
    Posted 3 years ago #

    Hello every one
    i am using this code to display the only subcategories in the main category page

    if (is_category()) {
      $this_category = get_category($cat);
      if (get_category_children($this_category->cat_ID) != "") {
        echo "";
        echo "<ul>";
        echo "</ul>";

    this codes works perfectly but i want to add image for the subcategories links (like post thumbnail) that image link to the subcategory?
    1) how i can add image for categories?
    2) how i can display thats images to the subcategories list?
    is this possible?

  2. shadez
    Posted 3 years ago #

    heard of a plugin th do this but not sure..
    workaround is to save images separately on server and then display via loop. instead of wp_list_categories, use get_categories with param 'child_of='.$this_category->cat_ID'. and then in a foreach loop, display each, which also gives you an option to output image..
    if its 1 image for all then give it as list-style in ul.

  3. omidgs
    Posted 3 years ago #

    shadez thank for your reply
    i have another idea for that
    can id display the first featured post thumbnail of subcategory with its name ?
    if this possible web have a grid of thumbs of subcategory in main category page that i like it
    is this possible?

  4. shadez
    Posted 3 years ago #

    oh yeah thats cool too... maybe this string will work:


    check it out and let know.. :)

  5. omidgs
    Posted 3 years ago #

    how i can use this ?
    please explain me width an example of usage

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.