• Hi guys,

    A fairly simple one (hopefully)…

    I need to list a custom post type’s taxonomies, along with the description and image for each.

    Like this – https://mockupr.com/mu/eiyk4557/sports-club-offers-homepage (see under ‘browse offers’)

    I want the outcome to be in list format and similar to how ‘wp_list_categories’ works in the way that it wraps the child categories in a separate ul (a different class for each child list would also be great). The reason for this is that I’d like to provide a drop down of child categories (or taxonomies) once the parent has been clicked (as you can see in the above mock up).

    My post type is called ‘offer’, with the taxonomy I’m targeting called ‘offer_category’.

    ANY help with this would be massively appreciated and I’ll surely owe you a beer or two ??

    Thanks,
    Luke

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Luke Etheridge

    (@luke-etheridge)

    Just to elaborate a little, I think this may simplify…

    It’s basically as simple as wanting to display all of the individual ‘post’ category and sub-category titles in a hierarchical list, along with each parent category’s image and description.

    BUT

    Instead relating it to a custom post type’s (‘offer’) taxonomy (offer_category).

    Again I think the mock up here should explain what I’m after: https://mockupr.com/mu/eiyk4557/sports-club-offers-homepage

    Or if you have another suggestion of how I should handle this sort of thing I’m all ears.

    Thanks,
    Luke

    Thread Starter Luke Etheridge

    (@luke-etheridge)

    Like so…

    [parent-image] Parent Category Title
    This is the parent description
    – Sub-category 1
    – Sub-category 2
    – Sub-category 3
    – Sub-category 4

    [parent-image] Parent Category Title
    This is the parent description
    – Sub-category 1
    – Sub-category 2
    – Sub-category 3

    Thread Starter Luke Etheridge

    (@luke-etheridge)

    Anyone have a resolve for this?

    I think the way is using wp_list_pages and use a custom walker… I′m trying that too ??

    I found a way.

    First create a wp_query to call the post_type parents then inside the while insert a new loop fo the childs

    <?php $custom_query = new WP_Query(array(
     'post_type' => 'CPTNAME',
     'post_parent' => 0,
     'posts_per_page' => -1
    ));?>
    <?php while ($custom_query->have_posts() ) : $custom_query->the_post(); ?>
    
    <?php
    $custom_childs = array(
    'post_type'	 =>	'CPTNAME',
    'posts_per_page' => -1,
    'post_parent' => $post->ID
    );
    $custom_childs_query = new WP_Query($custom_childs);
    ?>
    <?php if ($custom_childs_query->have_posts()) : ?>
     <?php while ($custom_childs_query->have_posts()) : $custom_childs_query->the_post(); ?>
      <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    <?php endwhile; ?>
    <?php endif; wp_reset_postdata(); ?>
    
    <?php endwhile; wp_reset_postdata(); ?>

    For me this works perfeclty ??

    More easy that use the walker ??

    Thread Starter Luke Etheridge

    (@luke-etheridge)

    Thanks lonchbox!!

    I’ve actually ended up crafting a rather sophisticated custom walker along with a guy named Mark here – https://stackoverflow.com/q/18121433/1635736

    I’ve actually achieved exactly what I was after which is cool ?? And it can be customised and manipulated within the WP Menu’s options.

    Hope this helps you anyway mate.

    nice option too, in my case was better the loop inside loop becasue my CPT have a hierarchy true ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘List Custom Post Type Taxonomies WITH Image and Description’ is closed to new replies.