custom post type ordered by category (custom taxonomy) on a page
-
Hello,
I would like to show my custom post type ordered by category (custom taxonomy)on a page, if possible also with the category name above the posts. But i dont know how i can do this. does anyone know the solution for this?
<?php $my_query = new WP_Query( $args = array( 'post_type' => 'cupcakes', 'taxonomy' => 'cupcake_category', 'field' => 'slug', 'terms' => 'specials') ); $query = new WP_Query( $args ); ?> <?php get_header(); ?> <section id="primary" class="content-area"> <div id="content" class="site-content" role="main"> <?php if ($my_query-> have_posts() ) : ?> <header class="page-header"> <h1 class="page-title"></h1> </header><!-- .page-header --> <div class="archive-posts"> <header class="entry-header"> <h1 class="entry-title"></h1> </header><!-- .entry-header --> <?php /* Start the Loop */ ?> <?php while ($my_query-> have_posts() ) : $my_query->the_post(); ?> <?php get_template_part( 'content', 'page-cupcakes');?> <?php endwhile; ?> </div> </div> <?php snaps_content_nav( 'nav-below' ); ?> <?php else : ?> <?php get_template_part( 'no-results', 'archive' ); ?> <?php endif; ?> </div><!-- #content .site-content --> </section><!-- #primary .content-area --> <?php get_footer(); ?>
This is how it looks so far (this is a created archive-cupcake.php file)
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘custom post type ordered by category (custom taxonomy) on a page’ is closed to new replies.