WordPress.org

Ready to get started?Download WordPress

Forums

List Custom Post Type Taxonomies WITH Image and Description (8 posts)

  1. Luke Etheridge
    Member
    Posted 1 year ago #

    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 - http://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

  2. Luke Etheridge
    Member
    Posted 1 year ago #

    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: http://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

  3. Luke Etheridge
    Member
    Posted 1 year ago #

    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

  4. Luke Etheridge
    Member
    Posted 1 year ago #

    Anyone have a resolve for this?

  5. lonchbox
    Member
    Posted 1 year ago #

    I think the way is using wp_list_pages and use a custom walker... I´m trying that too :P

  6. lonchbox
    Member
    Posted 1 year ago #

    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 ;)

  7. Luke Etheridge
    Member
    Posted 1 year ago #

    Thanks lonchbox!!

    I've actually ended up crafting a rather sophisticated custom walker along with a guy named Mark here - http://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.

  8. lonchbox
    Member
    Posted 1 year ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic