style / different content posts based on month
-
I’d like to style a post differently based on whether its this month, or any other previous month.
I.e. something like…
if (this_month) { get_template_part( 'content', 'post1' ) } else if (any_other prior_month) { get_template_part( 'content', 'post2') }
How can I go about this?
I found this snippet which is showing how to do a conditional statement based on time but don’t quite understand it:
<?php $w_h = $w_d = 0; ?> <?php while (have_posts()) : the_post(); ?> <?php if ( date('Yz') == get_the_time('Yz') ) { if (!$w_d++) echo 'Today<br />'; } elseif ( date('Yz')-1 == get_the_time('Yz') ) { if (!$w_h++) echo 'Yesterday<br />'; } else { echo the_date(); }; ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘style / different content posts based on month’ is closed to new replies.