How can I make thumbnails a display different size/position if the blog post was posted before a specific date?

I would like to be able to display the blog post’s thumbnail a smaller size and right floated if it was posted before April 11, 2019 but I can’t seem to figure it out.

This is what I tried:

<?php
global $post;
$compare_date = strtotime( “2018-03-01″ );
$post_date = strtotime( $post->post_date );

if (has_post_thumbnail() && ( $compare_date < $post_date ) ) {
echo ‘<div style=”float:right;padding-left:20px;”><img src=”‘.the_post_thumbnail().'” /></div>’;}
else {
echo ‘<img src=”‘.the_post_thumbnail().'” />’;}
?>

But when I did this, it affected all of my post thumbnails rather than just the ones before a specific date.

Any ideas?

Read more here:: How can I make thumbnails a display different size/position if the blog post was posted before a specific date?

Leave a Reply

Your email address will not be published. Required fields are marked *