Wordpress: Output a custom post type list by two Custom Taxonomies -
i need list out custom post type organised 2 different taxonomies on these posts.
i have custom post type of properties/apartments taxonomies of location , type/size trying list them out below
required layout
custom post type
apartment location
apartment size 1
- list item 1
- list item 2
- list item 3
apartment size 2
- list item 4
- list item 5
- list item 6
apartment location 2
apartment size 1
- list item 7
- list item 8
- list item 9
apartment size 2
- list item 10
- list item 11
- list item 12
i'm using current code it's spitting out under each taxonomy size? , cant filter location , size
<?php $terms = get_terms('apartment_location'); foreach( $terms $term ): ?> <h2><?php echo $term->name;?></h2> <?php $posts = get_posts(array( 'post_type' => 'apartments', 'taxonomy' => $term->taxonomy, 'term' => $term->slug, 'nopaging' => true )); ?> <?php $terms = get_terms('apartment_type'); foreach( $terms $term ): ?> <h3><?php echo $term->name;?></h3> <?php $posts = get_posts(array( 'post_type' => 'apartments', 'taxonomy' => $term->taxonomy, 'term' => $term->slug, 'nopaging' => true )); ?> <?php foreach($posts $post): setup_postdata($post); ?> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><br> <?php wp_reset_postdata();?> <?php endforeach; ?> <?php endforeach; ?> <?php wp_reset_postdata();?> <?php endforeach; ?>
Comments
Post a Comment