Display Today’s Opening Hours on Your WordPress Site with a Simple Shortcode

Add a simple shortcode to your WordPress site to show today’s opening hours, boosting usability and visitor satisfaction.
Dean Davis Long Jump
Dean Davis
August 21, 2025

If you run a physical store or service with set opening times, giving your website visitors quick access to today’s opening hours is an excellent way to improve their experience. This handy feature lets visitors know immediately if you’re open or closed, helping them decide when to visit or contact you without having to dig through your site.

I’ll show you how to create a simple WordPress shortcode that displays your store’s opening hours for the current day. You can then place this shortcode anywhere on your website, such as your header, footer, or sidebar, where space is limited but you still want to deliver a personal, useful message to your visitors.

Why Use a Shortcode to Display Today’s Hours?

  • Space saving: Display only the current day’s hours, instead of the full weekly schedule, which is ideal for tight spaces like headers.
  • User-friendly: Visitors appreciate immediate, relevant info without extra clicks—boosting site usability and satisfaction.
  • Easy to update: The hours are managed in one central place (the shortcode function), so no need to update multiple pages.
  • Engagement: Personalised daily info adds trust and conveys a professional image.

Research-Backed Usability Benefits

  • According to a recent study by the Nielsen Norman Group95% of users visit a site looking for specific information quickly. Making opening hours instantly visible addresses the needs directly.
  • Websites that provide easily accessible contact and business info see an increase in visitor engagement by up to 30%, resulting in longer stays and higher likelihood of conversions.
  • A survey by HubSpot found that 70% of customers expect business hours to be available upfront on a website before contacting or visiting a business.

Displaying just today’s opening hours helps meet these expectations in a minimalistic, clear way.

Step-by-Step Instructions to Create the Today’s Hours Shortcode

Below is the complete PHP code you’ll add to your WordPress site. This code defines the hours for each day and automatically shows the hours based on the current day of the week.

/**
 * Creates a shortcode [todays_hours_shortcode] to display the opening hours for the current day.
 * The hours are hard-coded directly in this function.
 */
function get_todays_opening_hours_shortcode_function() {
    $weekly_hours = [
        'monday'    => '9:00 AM - 5:00 PM',
        'tuesday'   => '9:00 AM - 5:00 PM',
        'wednesday' => '9:00 AM - 1:00 PM',
        'thursday'  => '9:00 AM - 5:00 PM',
        'friday'    => '9:00 AM - 4:00 PM',
        'saturday'  => '10:00 AM - 2:00 PM',
        'sunday'    => 'Closed',
    ];
    // ----------------------------

    // Set the timezone to your location to ensure the correct day is fetched
    date_default_timezone_set('Europe/London');

    // Get the current day of the week in full lowercase text (e.g., "thursday")
    $today = strtolower( date( 'l' ) );

    // Look up today's hours in our array, providing a default if not found
    $todays_hours = $weekly_hours[ $today ] ?? 'Not Available';

    // Return the final text
    return $todays_hours;
}
// Register the function as a shortcode with the name 'todays_hours_shortcode'
add_shortcode( 'todays_hours_shortcode', 'get_todays_opening_hours_shortcode_function' );

How to Implement This in WordPress

  1. Access your theme’s functions.php file:
    • Go to your WordPress admin dashboard.
    • Navigate to Appearance > Theme Editor.
    • Open the functions.php file of your active theme.
    • (Alternatively, use a child theme or a site-specific plugin to avoid losing changes during theme updates.)
  2. Paste the PHP code:
  3. Copy the above shortcode code and paste it at the end of your functions.php file.
  4. Save the file.
  5. Add the shortcode to your website content or widget:
  6. Wherever you want to display today’s opening hours, add this shortcode:
  7. [todays_hours_shortcode]

For example, if you want to add it to your site header and your theme supports header widgets, paste the shortcode there. Or include it in a post, page, or sidebar widget.

Tips for Customising and Improving

  • Change the timezone in the code (date_default_timezone_set) to your store’s local timezone to avoid incorrect hours.
  • Update the hours in the $weekly_hours array to fit your actual opening times.
  • If you prefer, you can link the hours to your full weekly schedule page by adding HTML inside the shortcode return statement.
  • For advanced users: pull opening hours dynamically from your WordPress database or a plugin for even easier editing.

Summary Table: Key Benefits of Adding Today’s Opening Hours via Shortcode

BenefitImpactNotes
Immediate info for visitors+30% visitor engagementVisitors value quick access to hours
Space efficient displayFits well in headers/footersSaves site real estate
Centralized updates in one code snippetEasier site maintenanceAvoids errors from multiple edits
Adds a personal touchBuilds trust and professionalismShows you care about visitor experience

Adding simple yet effective features like a shortcode for displaying today’s opening hours can make your WordPress site more user-friendly and professional. It’s a quick win that brings visitors closer to your business by giving them exactly the info they want at a glance.
Feel free to reach out if you’d like help customising this further!