How to display a module on a specific day of the week
December 2, 2022 | Beaver Builder, Tips & Tricks, WordPress
If you get a request asking to only have a module display on a specific day of the week, calendar year, or on a particular day here are the steps on setting this up.
Important Note: This set up can potentially cause performance issues and should be used only if the customer insists and acknowledges the potential performance issue it may cause.
Important Shortcodes
The following short codes can be used to not only display the current date in the front end of the website but also restrict the content using the modules conditional logic settings. The short codes will display the current date based on the customers WordPress time zone settings as follows:
[fl_year] = 2018
[fl_year format="y"] = 18
[fl_year format="F j, Y"] = May 26, 2018
[fl_year format="l, F j, Y"] = Saturday, May 26, 2018
[fl_year format="l"] = Saturday
PS: If you copy and paste this code and the quotation marks display in the output or only part of the date displays, try deleting and retyping the quotation marks – sometimes hidden formatting can sneak in.
Settings
- In the module or row settings go to the advanced tab
- Under the Visibility section choose Conditional logic
- Click the button that appears underneath labeled “Open Conditional Logic Settings”
- Under the first dropdown you will choose Shortcode result
- The second field will hold the shortcode, see above for shortcode information.
- The third field can be adjusted as you see fit , but you will most likely need the equals value
- The forth field will be the value of the shortcode you would like the module or row to be displayed on.
Example:
Task: Add Thursday Special Image to page. This image should only display on Thursdays.
- Add the Image module to the page and style appropriately.
- Go to the advanced tab and under visibility choose conditional logic
- Click the button that appears underneath labeled “Open Conditional Logic Settings”
- In the first dropdown choose “Shortcode result”
- In the second field enter the shortcode
[fl_year format="l"]
- In the 3rd field choose “equals”
- In the last field you will type in “Thursday”
- Save and Publish