<?php
$year = '';
if (have_posts()) : while (have_posts()) : the_post();
$current_year = get_the_date( 'Y' );
if ( $year != $current_year ) echo '<h4>---' . $current_year . '---</h4>';
?>
<article <?php post_class() ?> id="post-<?php the_ID(); ?>">
<h2><?php the_title(); ?></h2>
</article>
<?php
$year = $current_year;
endwhile; endif; ?>
$year = '';
while ( .... ) :
$current_year = get_the_date( 'Y' );
if ( $year != $current_year ) {
echo '<h4>---' . $current_year . '---</h4>';
// .....
}
$year = $current_year;
endwhile;
<script>
jQuery(document).ready(function(){
jQuery('a.spoiler-head').click(function(){
jQuery(this).next().toggle(200);
return false;
});
});
</script>
.spoiler {position:relative;}
.spoiler a.spoiler-head {display:block; float:left; margin:10px 0 2px 0; text-decoration:none;}
.spoiler a.spoiler-head span {padding:0; border-bottom:dashed 1px #71C83B; font-size:16px; color:#71C83B;}
.spoiler .spoiler-body {display:none; position:relative; padding:6px 0 0 0; margin:0; clear:both;}
<div class="spoiler">
<a class="spoiler-head" href="#">Внимание, спойлер!</a>
<div class="spoiler-body">Тут содержимое нашего супер простейшего спойлера</div>
<div class="clear"></div>
</div>