From de1225879097250dca257013aa362656c4a4843d Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Wed, 19 Jul 2017 14:40:03 -0400 Subject: [PATCH] Update CPT for packages Setup CPT so they can have parent posts. This way they can be sorted on the front end better. --- lib/troutcreek-packages.php | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/troutcreek-packages.php b/lib/troutcreek-packages.php index f7259dd..23537e7 100644 --- a/lib/troutcreek-packages.php +++ b/lib/troutcreek-packages.php @@ -62,7 +62,7 @@ function troutcreek_custom_post_type() 'labels' => $labels, 'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'page-attributes' ), 'taxonomies' => array( CATEGORY_SLUG ), - 'hierarchical' => false, + 'hierarchical' => true, 'public' => false, 'show_ui' => true, 'show_in_menu' => true, @@ -143,22 +143,22 @@ function troutcreekPackagesShortcode( $atts ) extract( shortcode_atts( array( 'limit' => '10' ), $atts ) ); ob_start(); global $wp; - $custom_terms = get_terms( CATEGORY_NAME ); + //$custom_terms = get_terms( CATEGORY_SLUG ); echo '
'; - foreach($custom_terms as $custom_term) { + //foreach($custom_terms as $custom_term) { wp_reset_query(); $args = array( 'posts_per_page' => -1, 'post_type' => POST_TYPE, 'orderby' => 'menu_order', 'order' => 'ASC', - 'tax_query' => array( - array( - 'taxonomy' => CATEGORY_NAME, - 'field' => 'slug', - 'terms' => $custom_term->slug, - ), - ), + //'tax_query' => array( + //array( + //'taxonomy' => CATEGORY_SLUG, + //'field' => 'slug', + //'terms' => $custom_term->slug, + //), + //), ); $loop = new WP_Query($args); @@ -169,6 +169,10 @@ function troutcreekPackagesShortcode( $atts ) while($loop->have_posts()) : $loop->the_post(); // Get the image $thumbnail = get_the_post_thumbnail( null, 'packageList' ); + if ( !$thumbnail ) { + echo '

' . get_the_title() . '

'; + continue; + } // Get the meta data $custom = get_post_custom(); //echo '
$custom: ' . print_r( $custom, true ) . '
'; @@ -202,7 +206,7 @@ function troutcreekPackagesShortcode( $atts ) echo '
'; } - } + //} echo ''; $output = ob_get_contents(); ob_end_clean(); -- 2.17.1