Using variables in do_shortcode()
-
Trying to use a variable with a php do_sortcode()
I have this shortcode: [pods name=”menu” where=”weekday.name=’monday'”]{@post_name}<br>[/pods]
It shows all the Menu posts with the Weekday taxonomy set to Monday.
I want to use a php DATE function to get the current weekday and have this:
<?php $today = date(l); echo do_shortcode( '[pods name="menu" where="weekday.name=' . $today . '"]<div class="menu-block">{@post_name}</div>[/pods]' ); ?>
But it returns nothing.
If I do this it works:
<?php $today = date(l); echo do_shortcode( '[pods name="menu" where="weekday.name='monday'"]<div class="menu-block">{@post_name}</div>[/pods]' ); ?>
I tried this – but it displays ALL Menus regardless of the Weekday taxonomy:
<?php $today = date(l); echo do_shortcode( '[pods name="menu" where="weekday.name='/"$today/"'"]<div class="menu-block">{@post_name}</div>[/pods]' ); ?>
What am I doing wrong?
Thanks!
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Using variables in do_shortcode()’ is closed to new replies.