1 должность для каждой категории на главной странице и подсчет этих должностей

То, что я пытаюсь сделать на своей домашней странице, – это вытащить последнее сообщение из каждой из 6 категорий, но тогда мне нужно переменную $ counter увеличить (+1) для каждого сообщения, чтобы я мог правильно их правильно подобрать.

Мне удалось отобразить последнее сообщение из каждой категории в правильном порядке, но, делая это, я не могу заставить $ counter работать правильно.

Любая помощь будет принята с благодарностью – спасибо!

<?php get_header(); ?> <div class="col1"> <?php if (get_option('woo_show_carousel') == 'true' AND !is_paged()) { include (TEMPLATEPATH . "/includes/featured.php");} ?> <?php if (is_paged()) $is_paged = true; if (get_option('woo_slider_exclude') == "true") $shownslides = get_option('woo_shown_slides'); if(empty($showslides) || get_option('woo_show_carousel') == 'false'){ $showslides = array(); } $showvideo = get_option('woo_show_video'); $vidtags = get_option('woo_video_tags'); if(!empty($vidtags)) { $vidtags_array = explode(',',$vidtags); } else { $vidtags_array = array(); } global $wpdb; foreach ($vidtags_array as $tag_name){ $tag_name = trim($tag_name); $tagid = $wpdb->get_var("SELECT term_ID FROM $wpdb->terms WHERE name='$tag_name'"); $tagids[] = $tagid; } $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $taxonomy = 'category';// eg post_tag, category $param_type = 'category__in'; // eg tag__in, category__in $term_args=array( 'include' => '3,4,5,6,11,14', 'orderby' => 'ID', 'order' => 'ASC' ); $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, 'post__not_in' => $shownslides, 'tag__not_in' => $tagids, 'paged'=> $paged ); query_posts($args); $home_content = get_option('woo_home_content'); $home_boxes = get_option('woo_home_boxes'); if (have_posts()) : $full = FALSE; $width = get_option('woo_full_thumb_width'); $height = get_option('woo_full_thumb_height'); if( $home_boxes == 'On') { $small = TRUE; } elseif ($home_boxes == 'Off') { $full = TRUE; } else { $large_posts = intval($home_boxes); } $counter = 0; while (have_posts()) : the_post(); $counter++; $post_class = 'full'; if( ($counter > $large_posts OR $small == TRUE) AND $full == FALSE) { $width = get_option('woo_boxed_thumb_width'); $height = get_option('woo_boxed_thumb_height'); if( $small == FALSE ) $counter = 1; $small = true; if ($counter%2 == 0 ) { $post_class = 'fr'; } else { $post_class = 'fl'; } } ?> <div class="post-outer post <?php echo $post_class; ?>"> <div class="post-inner post-alt"> <?php woo_get_image('image',$width,$height); ?> <h2><a title="<?php _e('Permalink to ',woothemes); ?><?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2> <p class="category-head cufon"><?php the_category(', ') ?></p> <?php if ($home_content == 'false') { ?> <p><?php echo strip_tags(get_the_excerpt(), '<a><strong>'); ?></p> <?php } else { ?> <?php the_content(__('Continue Reading',woothemes)); ?> <?php } ?> </div><!--/post-inner--> </div><!--/post--> <?php if ($counter%2 == 0 AND $small == TRUE ) { echo '<div style="clear:both;"></div>'; } ?> <?php endwhile; ?> <?php endif; } } wp_reset_query(); ?> <div class="more_entries"> <?php if (function_exists('wp_pagenavi')) wp_pagenavi(); else { ?> <div class="fl"><?php previous_posts_link(__('&laquo; Newer Entries ',woothemes)) ?></div> <div class="fr"><?php next_posts_link(__(' Older Entries &raquo;',woothemes)) ?></div> <br class="fix" /> <?php } ?> </div> <div class="fix"></div> <?php if (get_option('woo_show_video') == 'true') { include (TEMPLATEPATH . "/includes/video.php");} ?> <?php if (get_option('woo_show_talking_points') == 'true') { include (TEMPLATEPATH . "/includes/talking-points.php");} ?> </div><!--/col1--> 

Ну, после хорошего поиска я, похоже, работаю, надеюсь, это кому-то поможет.

  <div class="col1"> <?php if (get_option('woo_show_carousel') == 'true' AND !is_paged()) { include (TEMPLATEPATH . "/includes/featured.php");} ?> <?php if (is_paged()) $is_paged = true; if (get_option('woo_slider_exclude') == "true") $shownslides = get_option('woo_shown_slides'); if(empty($showslides) || get_option('woo_show_carousel') == 'false'){ $showslides = array(); } $showvideo = get_option('woo_show_video'); $vidtags = get_option('woo_video_tags'); if(!empty($vidtags)) { $vidtags_array = explode(',',$vidtags); } else { $vidtags_array = array(); } global $wpdb; foreach ($vidtags_array as $tag_name){ $tag_name = trim($tag_name); $tagid = $wpdb->get_var("SELECT term_ID FROM $wpdb->terms WHERE name='$tag_name'"); $tagids[] = $tagid; } $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $taxonomy = 'category';// eg post_tag, category $param_type = 'category__in'; // eg tag__in, category__in $term_args=array( 'include' => '3,4,5,6,11,14', 'orderby' => 'ID', 'order' => 'ASC' ); $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, 'post__not_in' => $shownslides, 'tag__not_in' => $tagids, 'paged'=> $paged ); query_posts($args); $home_content = get_option('woo_home_content'); $home_boxes = get_option('woo_home_boxes'); static $counter = 0; if (have_posts()) : $full = FALSE; $width = get_option('woo_full_thumb_width'); $height = get_option('woo_full_thumb_height'); if( $home_boxes == 'On') { $small = TRUE; } elseif ($home_boxes == 'Off') { $full = TRUE; } else { $large_posts = intval($home_boxes); } while (have_posts()) : the_post(); $counter++; $post_class = 'full'; if( ($counter > $large_posts OR $small == TRUE) AND $full == FALSE) { $width = get_option('woo_boxed_thumb_width'); $height = get_option('woo_boxed_thumb_height'); if( $small == FALSE ) $counter = 1; $small = true; if ($counter%2 == 0 ) { $post_class = 'fr'; } else { $post_class = 'fl'; } } ?> <div class="post-outer post <?php echo $post_class; ?>"> <div class="post-inner post-alt"> <?php woo_get_image('image',$width,$height); ?> <h2><a title="<?php _e('Permalink to ',woothemes); ?><?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2> <p class="category-head cufon"><?php the_category(', ') ?></p> <?php if ($home_content == 'false') { ?> <p><?php echo strip_tags(get_the_excerpt(), '<a><strong>'); ?></p> <?php } else { ?> <?php the_content(__('Continue Reading',woothemes)); ?> <?php } ?> </div><!--/post-inner--> </div><!--/post--> <?php if ($counter%2 == 0 AND $small == TRUE ) { echo '<div style="clear:both;"></div>'; } ?> <?php endwhile; ?> <?php endif; } } wp_reset_query(); ?> <div class="more_entries"> <?php if (function_exists('wp_pagenavi')) wp_pagenavi(); else { ?> <div class="fl"><?php previous_posts_link(__('&laquo; Newer Entries ',woothemes)) ?></div> <div class="fr"><?php next_posts_link(__(' Older Entries &raquo;',woothemes)) ?></div> <br class="fix" /> <?php } ?> </div> <div class="fix"></div> <?php if (get_option('woo_show_video') == 'true') { include (TEMPLATEPATH . "/includes/video.php");} ?> <?php if (get_option('woo_show_talking_points') == 'true') { include (TEMPLATEPATH . "/includes/talking-points.php");} ?> </div><!--/col1-->