Plugin Author
Steven
(@shazahm1hotmailcom)
Since you are using a profile template instead of one of the anniversary/birthday templates, the show_lastname option will have no effect; it can be removed from the shortcode. Example:
[upcoming_list template='profile' list_type='birthday' upcoming_list days='2' no_results='No birthdays today...']
The birthday type is the default, so you do not need the list_type option. Example:
[upcoming_list template='profile' upcoming_list days='2' no_results='No birthdays today...']
upcoming_list is not a shortcode option; this should be removed. Example:
[upcoming_list template='profile' days='2' no_results='No birthdays today...']
The days option has a trailing fancy quote ′ instead of a straight quote '. This can break the WordPress shortcode parser. This could lead to unexpected results.
Setting days to 0 will cause the list to show only the current day’s events; it does not filter based on the day of the week.
Please delete the entire shortcode on your page and manually type in the following; please do not copy-paste.
[upcoming_list template='profile' days=0 no_results='No birthdays today...']
I hope I have answered this clearly and thoroughly; please let me know.
Hi, sorry, I think I didn’t make myself clear enough. That shortcode I shared works perfectly, I don’t have any issues with it and it works as I expected. The problem is that I want to show the current birthdays ‘0’ only from Monday to Thursday, because on Fridays I want it to show the Friday + Weekend birthdays ‘2’. I have to change that value manually and I was wondering if it wasn’t a way to pass a value dynamic to that parameter (days)
-
This reply was modified 4 years, 2 months ago by
nibetanco.
Can I use something like this days={Date().includes(‘Fri’) ? ‘2’ : ‘0’} ?
Plugin Author
Steven
(@shazahm1hotmailcom)
Oh, I really sorry. I understand now.
Try this; note, this is completely untested code only off the top of my head.
Install the Code Snippets plugin and then add the following as a new code snippet. Save and Activate it.
add_filter(
'shortcode_atts_upcoming_list',
function( $atts ) {
$date = current_datetime();
$day = $date->format( 'N' );
if ( 5 > $day ) {
$atts['days'] = 0;
} else {
$atts['days'] = 2;
$atts['no_results'] = 'No birthdays this weekend...';
}
return $atts;
}
);
1 (Monday) — 7 (Sunday)
I hope this helps!
-
This reply was modified 4 years, 2 months ago by
Steven.
I did this in a test env that I have with the same page. I’m not sure if in the shortcode I have to remove the whole day parameter? It shows the birthdays I think by default (like for the whole month starting today)
I decided to add the days parameter again with the 0 value and it shows today’s birthdays. I’m not sure if the snippet is working or no.
-
This reply was modified 4 years, 2 months ago by
nibetanco.
Plugin Author
Steven
(@shazahm1hotmailcom)
It will not matter if the shortcode has the days parameter because the code snippet will always overwrite it.
I always get my comparison logic backward the first time, kind of like plunging in a USB device, lol…
Try changing> to < to see that works.
-
This reply was modified 4 years, 2 months ago by
Steven.
No, it works now, the problem was the $atts[‘day’] it should be $atts[‘days’]
Actually I also changed the if clause and compare $day==5 because I only want this behavior on Fridays. Thank you very much for your help
Plugin Author
Steven
(@shazahm1hotmailcom)
Great to hear this is a working solution for you.