Filter custom content by parent category and subcategory
-
I found this bit of code here that shows (supposed to) the posts in the child category. I took out a bunch of stuff I don’t need (I think).
I get the heading of taxonomy I’m viewing but none of my custom posts are loading. Can anybody help please? No posts loaded before I removed anything from the original code so I don’t think I broke anything>
<div class="overflow-container"> <?php $term = get_queried_object(); $tax = 'department'; $parents = $term->parent; $term_id = $term->term_id; if ($parents > 0 && is_tax($tax, $tax->name)){ $args = array( 'post_type' => 'project_post', 'posts_per_page' => -1, $tax => $term->name, ); echo "<h2>".$term->name."</h2>"; $wp_query = new WP_Query($args); if( $wp_query->have_posts() ): while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?> <article <?php $k = $style_index % $styles_count; echo "class=$style_classes[$k]"; $style_index++; ?>> <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <div class="entry-content"> <div class="thumbnail"> <!-- get featured image --> <?php $mobile = wp_get_attachment_image_src( get_post_thumbnail_id(), 'thumbnail' ); $tablet = wp_get_attachment_image_src( get_post_thumbnail_id(), 'medium' ) ; $desktop = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large' ) ; ?> <img data-interchange="[<?php echo $mobile[0]; ?>, (small)], [<?php echo $tablet[0]; ?>, (medium)], [<?php echo $desktop[0]; ?>, (large)]"> </div> <div class="excerpt"> <header> <h2><?php the_title(); ?></h2> </header> <?php the_excerpt(); ?> </div> </div> <a href="<?php the_permalink(); ?>" class="entry-overlay"></a> </div> </article> <?php endwhile; endif; wp_reset_postdata(); } ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Filter custom content by parent category and subcategory’ is closed to new replies.