J0106Preston
Forum Replies Created
Viewing 1 replies (of 1 total)
-
Forum: Themes and Templates
In reply to: Filtering Custom Post Type by Category and tag in LoopRequired some tweaking but worked great. Here’s the code I have for anyone curious… THANK YOU SO MUCH! (now to copy all of these custom post type posts into the buttoned-up posttype now…)
<h2 class="menu-header">Practice</h2> <?php $loop = new WP_Query(array( 'post_type' => 'menu_item', // This is the name of your CPT 'tax_query' => array( array( 'taxonomy' => 'catagory', // This is the name of your taxonomy 'field' => 'slug', 'terms' => array( 'main-menu' ), // This is your taxonomy term 'taxonomy' => 'post_tag', // This is the name of your taxonomy 'field' => 'slug', 'terms' => array( 'starters' ), // This is your taxonomy term ) ), 'posts_per_page' => -1, 'order' => 'ASC', 'orderby' => 'title' )); ?> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> <h3 class="menu-title"><?php the_title(); ?></h3> <div class="menuIngredients"><?php the_content(); ?></div> <h4 class="menuPrice">$<?php echo get_post_meta($post->ID,'price',true) ?></h4> <?php endwhile; wp_reset_postdata; ?> <h2 class="menu-header">Practice2</h2> <?php $loop = new WP_Query(array( 'post_type' => 'menu_item', // This is the name of your CPT 'tax_query' => array( array( 'taxonomy' => 'catagory', // This is the name of your taxonomy 'field' => 'slug', 'terms' => array( 'main-menu' ), // This is your taxonomy term 'taxonomy' => 'post_tag', // This is the name of your taxonomy 'field' => 'slug', 'terms' => array( 'EntreesLand' ), // This is your taxonomy term ) ), 'posts_per_page' => -1, 'order' => 'ASC', 'orderby' => 'title' )); ?> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
Viewing 1 replies (of 1 total)