Certain types of businesses like restaurants may wish to display content based on the day of the week (like daily specials).
The following code snippet is perfect for displaying any type of content from your WordPress database—Posts, Pages, or even Custom Post Types like Modular Content!
function content_by_day() { $days = array( 'Monday' => 18, 'Tuesday' => 37, 'Wednesday' => 219, 'Thursday' => 11, 'Friday' => 58, 'Saturday' => 323, 'Sunday' => 270); $today = date('l'); if (!empty($days[$today])) echo apply_filters('the_content', get_post_field('post_content', $days[$today])); }
In the code above, you’ll want to replace the integers in the $days
array with the IDs of content from your WordPress database.
Please note: You’ll also need to hook this function into place wherever you want the content to output.