Listing custom posts by year with the year as its heading
-
Hi I’m looking to list my custom posts like so
2013
custom post
custom post
custom post
custom post2012
custom post
custom post
custom post
custom post2011
custom post
custom post
custom post
custom postI would like it to be dynamic, like if the user creates a new post in 2014, a new header, 2014, would be created and the post displayed under it.
I have very little programming knowledge but let me just paste what I have for my page (listed by taxonomy)
<div id="main" class="group"> <h2><?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); echo $term->name; ?></h2> <div id="gallerywrap" class="group"> <?php global $query_string; query_posts($query_string . '&posts_per_page=-1');?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php $custom = get_post_custom($post->ID); $image_html= get_the_post_thumbnail($post->ID, 'medium'); ?> <div class="group"> <div class="info"> <h3><?php echo the_title(); ?></h3> <p><?php the_content(); ?></p> </div> <?php print $image_html; ?> </div> <?php endwhile; else: ?> <p><?php _e('No posts were found. Sorry!'); ?></p> <?php endif; ?> </div> </div>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Listing custom posts by year with the year as its heading’ is closed to new replies.