WordPress.org

Ready to get started?Download WordPress

Forums

Taxonomy Images
Use on separate page, get only Parent categories (2 posts)

  1. pfenya
    Member
    Posted 2 years ago #

    I've been customizing the output of the plugin in the last few days for usage in a few different scenarios on a page we are building and it is really working great for all of them with one exception that I hope someone can help me with:

    The images are used for a custom taxonomy that is used together with a custom post type to show recipes. The goal now is to have an overview page that simply lists the first level of taxonomy categories (e.g. Desserts, Fingerfood, etc.). However, I can only get it to show all taxonomies, so, for example, i Desserts has the child Cakes but I would like to only show Dessert on the overview page. With my current code both are shown and unfortunately, my PHP skills are almost nonexistent, so I cannot get it to filter the results like I would need them to :(

    Here is the code I am using:

    $terms = apply_filters( 'taxonomy-images-get-terms', '', array('taxonomy'=>'food') );
    
    if ( ! empty( $terms ) ) {
    
    foreach( (array) $terms as $term ) {
    echo '<div class="product_category_item product"><div class="post-thumbnail"><a href="?food=' . $term->slug . '">' . wp_get_attachment_image( $term->image_id, 'thumbnail' , 'taxonomy-image' ) . '</a></div><h3 class="entry-title"><a href="?food=' . $term->slug . '">'.$term->name.'</a></h3></div>';
    };
    
    }

    http://wordpress.org/extend/plugins/taxonomy-images/

  2. Ruud Evers
    Member
    Posted 2 years ago #

    Did you ever manage to resolve this? I am looking for a similar solution.

    The code I use displays all child taxonomies (disregarding the parent taxonomy), but only those who have posts.

    [41 lines of code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic