HI, scratching my head on how to do this…
Site I’m building needs a specific bit of text to appear each day. I was going to use a repeater with a date & text field.
How could I filter it so it shows only the text for todays date?
Thanks in advance!
You could setup your repeater field with a date and text field (see attached image). Then under the selected page / post type, just fill the repeater rows with dates (using date picker) and corresponding dates.
Then on the page (I’m using a custom post type “Movies” in this example – and a template “single-movie.php”) just put this PHP code to get “quote of the day”:
<?php
// GET TODAY'S DATE IN THE SAME FORMAT AS YOUR DATE SUB-FIELD
$today = date('Ymd'); // 20140503
// CHECK IF REPEATER HAS ROWS
if( have_rows('quote_of_the_day') ):
// LOOP TROUGH REPEATER ROWS
while ( have_rows('quote_of_the_day') ) : the_row();
// IF THE REPEATER SUB-FIELD MATCHES TODAY'S DATE, SHOW QUOTE SUB FIELD
if (get_sub_field('date') == $today) {
the_sub_field('quote');
}
endwhile;
endif;
?>