Custom Post Type page by category
-
Hi,
I’m using CPT to show categories:<?php //list terms in a given taxonomy using wp_list_categories (also useful as a widget) $orderby = 'name'; $show_count = 0; // 1 for yes, 0 for no $pad_counts = 0; // 1 for yes, 0 for no $hierarchical = 1; // 1 for yes, 0 for no $taxonomy = 'category'; $title = 'LISTA'; $args = array( 'orderby' => $orderby, 'show_count' => $show_count, 'pad_counts' => $pad_counts, 'hierarchical' => $hierarchical, 'taxonomy' => $taxonomy, 'title_li' => $title ); ?> <ul> <?php wp_list_categories($args); ?> </ul>And works fine.. but, I would like to show relative post for each selected category, I try with this:
<?php //Custom Loop $args = array( 'post_type' => 'prodotti_accessori', 'posts_per_page' => 10 ); $loop = new WP_Query( $args ); //Custom Loop if( $loop->have_posts() ) : while ( $loop->have_posts() ) : $loop->the_post(); ?> <h2><?php the_title(); ?></h2> <div class="post"> <?php the_content(); ?> </div> <?php endwhile; endif; ?>But it shows ALL posts of CPT. How I could I do?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Custom Post Type page by category’ is closed to new replies.