Timeline with categories
-
Hi Everyone.
I’m trying to make a timeline with posts in het categorie “timeline” and with as children the years. So i used to a code i found here:
http://wordpress.org/support/topic/listing-child-categories-and-posts-1?replies=5and i want to make a 2 column stucture so i used this tutorial:
http://perishablepress.com/two-column-horizontal-sequence-wordpress-post-order/
And i wanted to combine them.So i get made this piece:
<?php //get terms (e.g. categories or post tags), then display all posts in each retrieved term $taxonomy = 'category';// e.g. post_tag, category $param_type = 'category__in'; // e.g. tag__in, category__in $term_args=array( 'orderby' => 'name', 'order' => 'DESC', 'child_of' => 5 ); $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', 'showposts' => -1, 'caller_get_posts'=> 1 ); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() ) { echo '<div class="year_cntr"><ul class="photos_left">'; $count = 0; while ($my_query->have_posts()) : $i++; if(($i % 2) == 0) : $my_query->next_post(); else : $my_query->the_post(); ?> <?php $count++; ?> <li> <div class="photo_cntr" style="float: right;"> <div class="cell"><?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'photo', array('class' => 'photo_'.$count.'') ); } ?><h3><?php the_title(); ?></h3><?php the_content() ?> </div> </div> </li> <?php endif; ?> <?php endwhile; } echo '</ul><ul class="photos_right">'; $i = 0; rewind_posts();; while ($my_query->have_posts()) : $i++; if(($i % 2) !== 0) : $my_query->next_post(); else : $my_query->the_post(); $count++;?> <li> <div class="photo_cntr" style="float: left;"> <div class="cell"> <?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'photo', array('class' => 'photo_'.$count.'') ); } ?> <h4><?php the_title(); ?> </h4> <?php the_content() ?> </div> </div> </li> <?php endif; ?> <?php endwhile; echo '</ul><div class="yearstamp">' . $term->name. '</div></div>'; } echo 'test'; } wp_reset_query(); // Restore global post data stomped by the_post(). ?>
This thing works OK for some children categories, but others give the same results in the “<ul class=”photos_left”>” as in the “<ul class=”photo_right”>”.
And i’m really stuck on this because i don’t know why??!?!?!
English is not my native tongue and my coding is noob style, so i hope this problem is readable.
Greets from Amsterdam,
Erik
- The topic ‘Timeline with categories’ is closed to new replies.