Widgets Which Display Automatically For Each Day Of The Week

This post includes the PHP code which creates 7 custom widgets for each day of the week.

The content you populate in each days widget will automatically display depending on which day it is.

The PHP code below should be copied and pasted at the end of your child themes functions.php file.

Change Position Of Widget Content

Change the hook position from genesis_before_loop to another if you want to change the location of your daily widget message.

This code changes the position the daily widgets display to the header right widget area and also adds the date which is dynamically generated.

Styling Your Widgets

Note the styling only applies to the first code snippet and the second snippet uses the .today class which you’ll need to use in a new rule with your own CSS declarations. The styling for these widgets uses the CSS code from Brian Gardners colored content boxes so you don’t need to add any CSS if you already use StudioPress code for the boxes on your site.

Otherwise, follow this tutorial which provides a link to the code you can copy and paste into your child themes style.css file.

You could also try using an existing class to style your widgets all the same or add your own CSS rules to the existing classes or change them for each widget.

Note: This code works based on the server time and not the timezome set in your General settings. Thanks to Stewart Chamberlain for helping with the testing and the idea for this code.

Related Posts


Comments

Leave a Reply