Show category and posts
-
Hi there!
I try to add a loop through all categories and show the posts within. It’s a cpt with a custom taxonomy “themen”.
I have this code but it doesn’t work:
$taxonomy = 'themen'; $terms = get_terms($taxonomy); // Get all terms of a taxonomy if ( $terms && !is_wp_error( $terms ) ) { foreach ( $terms as $term ) { $cat_id= $term->term_id; ?> <h2><?php echo $term->name; ?></h2> <?php $args = array( 'p' => $pdf, 'post_type' => $post_type, 'post_status' => 'publish', cat=> $cat_id ); $the_query = new WP_Query( apply_filters( 'dkpdf_query_args', $args ) ); if ( $the_query->have_posts() ) { while ( $the_query->have_posts() ) { $the_query->the_post(); global $post; ?> <div class="dkpdf-content"> <?php the_content(); ?> </div> <?php } } else { echo 'no results'; } wp_reset_postdata(); } }
Any idea, what’s wrong?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Show category and posts’ is closed to new replies.