Wrap the date only if there is a value
-
Hi and thanks for the plugin! Nice and easy in backend.
Now with my poor PHP knowledge I’m trying to show a post list where there are normal posts and event posts. I want to show the event date in its own box, and not show the box at all when there is no event date. Check https://tinyurl.com/jmpjcoz
I tried this IF sentence, but the box is there even though it has no value. I also tried it with isset: if (isset($mem_date)), but the result was the same, empty box was there when no event date.
<?php
$mem_date = mem_date_processing(get_post_meta($post->ID, ‘_mem_start_date’, true));
if (!empty($mem_date)){
echo ‘<div class=”meta-info”><div class=”meta-date”><span class=”month”>’;
echo date_i18n( ‘M’, $mem_date[“start-unix”] );
echo ‘</span><span>’;
echo date_i18n( ‘d’, $mem_date[“start-unix”] );
echo ‘</span></div></div>’;
}
?>
- The topic ‘Wrap the date only if there is a value’ is closed to new replies.