Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $years = $wpdb->get_col("SELECT DISTINCT YEAR(post_date) FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date DESC");
- foreach($years as $year) : ?>
- <h4><?php echo $year; ?></h4>
- <?php $theids = $wpdb->get_results("
- SELECT ID, post_title, post_excerpt
- FROM $wpdb->posts
- INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)
- INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
- WHERE post_status = 'publish'
- AND YEAR(post_date)= '".$year."'
- AND $wpdb->term_taxonomy.taxonomy = 'category'
- AND $wpdb->term_taxonomy.term_id IN ('1')
- ORDER BY post_date ASC
- ");
- foreach ($theids as $theid): ?>
- <div class="news">
- <h2><a href="<?php bloginfo('url'); ?>?p=<?php echo $theid->ID; ?>"><?php echo $theid->post_title; ?></a></h2>
- <?php echo $theid->the_excerpt; ?>
- <a href="<?php bloginfo('url'); ?>?p=<?php echo $theid->ID; ?>" class="s-btn">Read More »</a>
- <hr />
- </div>
- <?php endforeach; ?>
- <?php endforeach; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement