Diwali, the festival of lights, is a time of celebration and spreading joy. As a WordPress website owner, adding a personal touch to your site during this festive season can help connect with your audience and increase engagement. In this tutorial, we’ll walk you through how to display random Diwali wishes on your WordPress website using a simple shortcode. Whether you’re a developer or a WordPress enthusiast, this guide will make it easy to add some festive cheer to your site.
Why Add Diwali Wishes to Your Website?
Celebrating festivals like Diwali with your audience not only enhances the festive spirit but also improves user engagement on your website. By adding customized Diwali wishes, you show that your website is active and in tune with current events. A festive website is more likely to attract visitors, leading to higher traffic and engagement.
Step-by-Step Guide to Adding Diwali Wishes Shortcode to WordPress
1. Create a Diwali Wishes Shortcode
First, you’ll need to create a WordPress shortcode that will display a random Diwali greeting. Here’s a code snippet you can add to your theme’s functions.php
file:
2. Add the Shortcode to Your Pages or Posts
Once you’ve added the shortcode code, using the Diwali greeting on your site is easy. Simply add the shortcode
[diwali_wish]
to any post, page, or widget, and a random Diwali wish will appear. The message will change each time the page is loaded, creating a dynamic and engaging experience for your visitors.
Result
Customize the Diwali Wishes
If you’d like to customize the look and feel of the Diwali greeting, you can modify the CSS styles in the shortcode code. For instance, you can change the background image, text color, or font size to match your site’s design. Here’s how you can tweak the style:
<p class="diwali-content" style="max-width: 320px; color: white; background-image: url('https://i.ibb.co/fNhQYHM/happy-diwali-2.jpg'); padding: 10px 10px 100px 10px; font-weight: bold; text-align: center; background-size: 100% 100%; border: 1px solid #ddd; margin: 0 auto;"></p>
Additionally, feel free to add or modify the Diwali wishes in the JSON array to reflect your personal message to your audience.
Benefits of Using a Shortcode for Diwali Wishes
- Easy Integration: No need for a plugin. You can add the shortcode directly to your theme.
- Customization: Style the Diwali wishes to match your brand’s design.
- User Engagement: Keeps your content dynamic and fresh by showing different messages on each page load.
- SEO-Friendly: Adding relevant festive content such as Diwali wishes can boost your site’s ranking during the festive season, attracting users searching for Diwali greetings and messages.