Hallo,
ich habe folgende Konstellation.
Snippet:
function textvonbis_shortcode( $atts ) {
$a = shortcode_atts(
array(
'text' => 'Text fehlt',
'von' => '1900-01-01',
'bis' => '2099-12-31',
), $atts
);
$now = new DateTime( 'now' );
$date1 = new DateTime( $a['von'] );
$date2 = new DateTime( $a['bis'] );
if ( $now >= $date1 && $now <= $date2 ) {
return $a['text'];
} else {
__return_false();
}
}
add_shortcode( 'textvonbis', 'textvonbis_shortcode' );
Testseite:
[textvonbis Text='Hurra es klappt' von='2017-09-20' bis='2018-09-25']
<br><br><br>
[textvonbis Text='Hurra es klappt' von='2017-09-20' bis='2019-09-25']
<br><br><br>
Ergebnis:
Hurra es klappt Hurra es klappt
[size=12]Warum erfolgt kein Zeilenvorschub?[/SIZE]