How To Exclude Drafts from Archive
-
My sidebar’s archive list is by year. How do I exclude the year of drafts (year 0) from the php or SQL? Here’s my code:
<ul>
<?php
$years = $wpdb->get_col("SELECT DISTINCT YEAR(post_date) FROM $wpdb->posts ORDER BY post_date DESC");
foreach($years as $year) : ?>
<li><a href="<?php echo get_year_link($year); ?> "><?php echo $year; ?></a></li>
<?php endforeach; ?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How To Exclude Drafts from Archive’ is closed to new replies.