Getting post meta to display in sub-category
-
<?php $taxonomy = 'category'; $param_type = 'category__in'; $cat_id = get_cat_ID('Dining'); $term_args=array( 'orderby' => 'name', 'order' => 'DES', 'child_of' => $cat_id ); $terms = get_terms($taxonomy,$term_args); if ($terms) { foreach( $terms as $term ) { $args=array( "$param_type" => array($term->term_id), 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => -1, 'caller_get_posts'=> 1 ); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() ) { $name = $term->name; $slug = $term->slug; echo '<div class="separate"></div>'; echo '<div class="dinewrap">'; echo '<span>'.$term->name.'<dt class="tdown"></dt></span>'; echo '<div id="gwrap">'; echo '<ul class="dineimg">'; $resortimages = get_post_meta(get_the_ID(), 'wpcf-dining-indochine' ); foreach ($resortimages as $resortimage) { echo '<li><img src="'. $resortimage. '"/></li>'; } echo '</ul>'; while ($my_query->have_posts()) : $my_query->the_post(); echo '<div class="box group">'; if ( has_post_thumbnail() ) { the_post_thumbnail(); } ?> <h5><?php the_title(); ?></h5> <p><?php the_content(); ?></p> <?php echo '</div>'; endwhile; echo '</div>'; } echo '</div>'; } } wp_reset_query(); // Restore global post data stomped by the_post(). ?>
What I have currently is a Page displaying the Category ‘Dining’
It also displays the sub-categories’ posts dynamically.it displays like this :
Dining
-subcategory
–subcategory’s post
–subcategory’s post
–subcategory’s post
-subcategory
–subcategory’s post
–subcategory’s postWhat I’m trying to do is to insert images from a post meta to each subcategory section.
this code
$resortimages = get_post_meta(get_the_ID(), 'wpcf-dining-indochine' ); foreach ($resortimages as $resortimage) { echo '<li><img src="'. $resortimage. '"/></li>'; }
kind of works but it displays the images only in the first sub category. it doesnt display in the rest.
im hoping to display different sets of images to the different sub-categories
so something like
if subcategory is ‘id or name’, display these imagescan anyone help please??
- The topic ‘Getting post meta to display in sub-category’ is closed to new replies.