• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Date Detection with Automated Message

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Date Detection with Automated Message

This topic is: resolved
  • This topic has 6 replies, 3 voices, and was last updated 13 years ago by Brad Dalton.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • July 12, 2013 at 4:17 pm #50470
    electricbrick
    Participant

    Looking for a resource to automatically detect the server date (much like the Genesis right side extras does) but to also output a message based on the day of the week (i.e. open or closed). Anyone know of a simple PHP script or plugin that'll accomplish this?

    July 13, 2013 at 4:25 am #50525
    Stewart
    Member

    Hi,

    This is one simple way you can display message on the day of the week:

    add_action( 'genesis_footer', 'sc_date_closed' );
    function sc_date_closed() {
    	if( date ( 'w' ) == 5 ) {
    		echo 'closed';
    	}
    	else {
    		echo 'open';
    	}
    }
    

    All you will need to do is change the hook location from genesis_footer to where you want to display, and then just change the day, in the example above I used 5 which is friday.

    Sunday - Saturday = 0-6

    This is just a simple example but hope it puts you on the right track.

    Stewart


    WordPress Developer – Need help upgrading to Genesis 2.0? – My Blog
    Follow me on Twitter

    July 13, 2013 at 6:59 am #50537
    Brad Dalton
    Participant

    I forked Stewart's code and used it to create a widget for each day of the week.

    For styling it uses Brian Gardners colored content box CSS code so all you need to do is add the CSS code to the end of your child themes style.css file.


    Tutorials for StudioPress Themes.

    July 15, 2013 at 11:44 am #50817
    electricbrick
    Participant

    Holy smokes, Stewart & Brad -- you guys really came through. Thanks a ton!

    I took it a little further and amended the code to work in the header widget area and output the WordPress date:

    add_action( 'genesis_header_right', 'week_day_widgets' );
    function week_day_widgets() {
    if ( is_home || is_single() || is_page || is_archive )
        if ( date ( 'w' ) == 1 ) {
            echo '<div class="today"><p>Today is ' . date(get_option('date_format')) . '</p>';
            dynamic_sidebar( 'mondays-widget' );
            echo '</div><!-- end .mondays-widget -->';
    	}
    	else if( date ( 'w' ) == 2 ) {
            echo '<div class="today"><p>Today is ' . date(get_option('date_format')) . '</p>';
            dynamic_sidebar( 'tuesdays-widget' );
            echo '</div><!-- end .tuesdays-widget -->';
    	}
    	else if( date ( 'w' ) == 3 ) {
             echo '<div class="today"><p>Today is ' . date(get_option('date_format')) . '</p>';
            dynamic_sidebar( 'wednesdays-widget' );
            echo '</div><!-- end .wednesdays-widget -->';
    	}
    	else if( date ( 'w' ) == 4 ) {
             echo '<div class="today"><p>Today is ' . date(get_option('date_format')) . '</p>';
            dynamic_sidebar( 'thursdays-widget' );
            echo '</div><!-- end .thursdays-widget -->';
    	}
    	else if( date ( 'w' ) == 5 ) {
             echo '<div class="today"><p>Today is ' . date(get_option('date_format')) . '</p>';
            dynamic_sidebar( 'fridays-widget' );
            echo '</div><!-- end .fridays-widget -->';
            }
            else if( date ( 'w' ) == 6 ) {
             echo '<div class="today"><p>Today is ' . date(get_option('date_format')) . '</p>';
            dynamic_sidebar( 'saturdays-widget' );
            echo '</div><!-- end .saturdays-widget -->';
            }
            else if( date ( 'w' ) == 0 ) {
            echo '<div class="today"><p>Today is ' . date(get_option('date_format')) . '</p>';
            dynamic_sidebar( 'sundays-widget' );
            echo '</div><!-- end .sundays-widget -->';
            }
    
    }
    July 15, 2013 at 11:56 am #50824
    Brad Dalton
    Participant

    Tested and works perfectly.

    I removed all the conditionals so it displays site wide.


    Tutorials for StudioPress Themes.

    July 15, 2013 at 1:59 pm #50853
    electricbrick
    Participant

    Brad, you may want to note in your post that the block of code I contributed doesn't contain Brian's content box styling.

    July 15, 2013 at 2:16 pm #50854
    Brad Dalton
    Participant

    Ok, i'll add that thanks.


    Tutorials for StudioPress Themes.

  • Author
    Posts
Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble