WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. omidgs
    Member
    Posted 1 year ago #

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

    <?php
    if (is_category()) {
      $this_category = get_category($cat);
      if (get_category_children($this_category->cat_ID) != "") {
        echo "";
        echo "<ul>";
        wp_list_categories('orderby=id&show_count=0&title_li=
    &use_desc_for_title=1&child_of='.$this_category->cat_ID);
        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
    Member
    Posted 1 year 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
    Member
    Posted 1 year 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
    Member
    Posted 1 year ago #

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

    query_posts('category_name='.$category->name.'&showposts=1')

    check it out and let know.. :)

  5. omidgs
    Member
    Posted 1 year ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.