{"id":3420,"date":"2023-05-18T14:33:06","date_gmt":"2023-05-18T14:33:06","guid":{"rendered":"https:\/\/www.webmastersdesktop.com\/website-design-for-business\/?p=3420"},"modified":"2025-04-10T15:14:37","modified_gmt":"2025-04-10T15:14:37","slug":"add-current-year-to-woocommerce-emails-using-yaymail","status":"publish","type":"post","link":"https:\/\/www.webmastersdesktop.com\/blog\/add-current-year-to-woocommerce-emails-using-yaymail\/","title":{"rendered":"Add Current Year to WooCommerce Emails using YayMail"},"content":{"rendered":"\n<p>In WordPress, shortcodes are a powerful feature that allows you to add dynamic content to your posts, pages, or widgets. In this tutorial, we will walk you through the process of adding a custom shortcode to add the current year to WooCommerce Emails using the YayMail &#8211; WooCommerce Email Customizer plugin. By following these simple steps, you&#8217;ll be able to show the current year dynamically on your WooCommerce emails without any manual updates.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-1-install-and-activate-the-yaymail-woocommerce-email-customizer-plugin\">Step 1: Install and Activate the YayMail &#8211; WooCommerce Email Customizer Plugin <\/h3>\n\n\n\n<p>Before adding the custom shortcode, you need to install and activate the YayMail &#8211; WooCommerce Email Customizer plugin. This plugin enhances the customization options for WooCommerce email templates.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Log in to your WordPress admin dashboard.<\/li>\n\n\n\n<li>Navigate to &#8220;Plugins&#8221; and click on &#8220;Add New&#8221;.<\/li>\n\n\n\n<li>Search for &#8220;YayMail &#8211; WooCommerce Email Customizer&#8221;.<\/li>\n\n\n\n<li>Click on &#8220;Install Now&#8221; and then &#8220;Activate&#8221; to activate the plugin.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"568\" height=\"311\" src=\"https:\/\/www.webmastersdesktop.com\/blog\/wp-content\/uploads\/2023\/05\/yay-mail.png\" alt=\"YayMail \u2013 WooCommerce Email Customizer Plugin\" class=\"wp-image-3422\" srcset=\"https:\/\/www.webmastersdesktop.com\/blog\/wp-content\/uploads\/2023\/05\/yay-mail.png 568w, https:\/\/www.webmastersdesktop.com\/blog\/wp-content\/uploads\/2023\/05\/yay-mail-300x164.png 300w\" sizes=\"auto, (max-width: 568px) 100vw, 568px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-2-access-the-functions-php-file\">Step 2: Access the &#8216;functions.php&#8217; File <\/h3>\n\n\n\n<p>To get started, you need to access the <code>functions.php<\/code> file of your WordPress theme. This file is responsible for managing various functionalities of your theme.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Log in to your WordPress admin dashboard.<\/li>\n\n\n\n<li>Navigate to &#8220;Appearance&#8221; and click on &#8220;Theme Editor&#8221;. Make sure you have the appropriate permissions to edit theme files.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"837\" height=\"238\" src=\"https:\/\/www.webmastersdesktop.com\/blog\/wp-content\/uploads\/2023\/05\/custom-yay-mail-short-code.png\" alt=\"functions.php file\" class=\"wp-image-3421\" srcset=\"https:\/\/www.webmastersdesktop.com\/blog\/wp-content\/uploads\/2023\/05\/custom-yay-mail-short-code.png 837w, https:\/\/www.webmastersdesktop.com\/blog\/wp-content\/uploads\/2023\/05\/custom-yay-mail-short-code-300x85.png 300w, https:\/\/www.webmastersdesktop.com\/blog\/wp-content\/uploads\/2023\/05\/custom-yay-mail-short-code-768x218.png 768w\" sizes=\"auto, (max-width: 837px) 100vw, 837px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-3-locate-and-edit-the-functions-php-file\">Step 3: Locate and Edit the &#8216;functions.php&#8217; File <\/h3>\n\n\n\n<p>Once you are in the Theme Editor, locate and edit the <code>functions.php<\/code> file. It is typically located under your currently active theme&#8217;s folder.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-4-add-the-custom-shortcode-code-inside-the-functions-php-file\">Step 4: Add the Custom Shortcode Code Inside the &#8216;functions.php&#8217; file<\/h3>\n\n\n\n<p>Add the following code snippet:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_filter(\n    'yaymail_customs_shortcode',\n    function( $shortcode_list ) {\n        $current_year = date('Y');\n        $shortcode_list&#91;'&#91;yaymail_custom_shortcode_year]'] = $current_year;\n        return $shortcode_list;\n    }\n);<\/code><\/pre>\n\n\n\n<p>This code registers a custom shortcode <code>[yaymail_custom_shortcode_year]<\/code> that will display the current year dynamically.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-5-save-the-changes\">Step 5: Save the Changes <\/h3>\n\n\n\n<p>After adding the code, click on the &#8220;Update File&#8221; button to save the changes made to the <code>functions.php<\/code> file.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-6-utilize-the-custom-shortcode\">Step 6: Utilize the Custom Shortcode<\/h3>\n\n\n\n<p>Now that the custom shortcode has been added, you can use it within the email templates with YayMail &#8211; WooCommerce Email Customizer plugin.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Navigate to &#8220;YayMail&#8221; in your WordPress admin dashboard.<\/li>\n\n\n\n<li>Customize the desired email template that you want to include the current year in.<\/li>\n\n\n\n<li>In the email template editor, insert the shortcode <code>[yaymail_custom_shortcode_year]<\/code> at the desired location.<\/li>\n\n\n\n<li>Save the changes to the email template.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"534\" src=\"https:\/\/www.webmastersdesktop.com\/blog\/wp-content\/uploads\/2023\/05\/yay-mail-shortcode-in-footer-1024x534.png\" alt=\"Shortcode in Action\" class=\"wp-image-3423\" srcset=\"https:\/\/www.webmastersdesktop.com\/blog\/wp-content\/uploads\/2023\/05\/yay-mail-shortcode-in-footer-1024x534.png 1024w, https:\/\/www.webmastersdesktop.com\/blog\/wp-content\/uploads\/2023\/05\/yay-mail-shortcode-in-footer-300x157.png 300w, https:\/\/www.webmastersdesktop.com\/blog\/wp-content\/uploads\/2023\/05\/yay-mail-shortcode-in-footer-768x401.png 768w, https:\/\/www.webmastersdesktop.com\/blog\/wp-content\/uploads\/2023\/05\/yay-mail-shortcode-in-footer-1536x802.png 1536w, https:\/\/www.webmastersdesktop.com\/blog\/wp-content\/uploads\/2023\/05\/yay-mail-shortcode-in-footer.png 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h3>\n\n\n\n<p>By following the above steps, you have successfully added a custom shortcode to display the current year in your WordPress site using the YayMail &#8211; WooCommerce Email Customizer plugin. Now, your WooCommerce email templates will automatically show the current year, providing a dynamic and up-to-date experience for your customers.<\/p>\n\n\n\n<p>Looking for expert assistance with WordPress, WooCommerce, or email customization? Look no further! At Webmaster&#8217;s Desktop, our experienced team is here to help you overcome any challenges you may be facing. Whether you need help setting up your WordPress site, customizing your WooCommerce store, or enhancing your email templates, we&#8217;ve got you covered. Contact us today and let us handle the technical aspects while you focus on growing your business. Unleash the full potential of your online presence with Webmaster&#8217;s Desktop.<\/p>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/www.webmastersdesktop.com\/contactus.php\" target=\"_blank\" rel=\"noreferrer noopener\">Get Help<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Discover how to effortlessly add the current year to WooCommerce emails using a custom shortcode. By incorporating the YayMail &#8211; WooCommerce Email Customizer plugin, you can easily customize email templates and add the dynamic current year shortcode.<\/p>\n","protected":false},"author":2,"featured_media":3424,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_gspb_post_css":"","footnotes":""},"categories":[16,36],"tags":[50,48,49],"class_list":["post-3420","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ecommerce","category-wordpress","tag-shortcodes","tag-woocommerce","tag-yaymail"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/www.webmastersdesktop.com\/blog\/wp-json\/wp\/v2\/posts\/3420","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webmastersdesktop.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webmastersdesktop.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webmastersdesktop.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webmastersdesktop.com\/blog\/wp-json\/wp\/v2\/comments?post=3420"}],"version-history":[{"count":3,"href":"https:\/\/www.webmastersdesktop.com\/blog\/wp-json\/wp\/v2\/posts\/3420\/revisions"}],"predecessor-version":[{"id":3890,"href":"https:\/\/www.webmastersdesktop.com\/blog\/wp-json\/wp\/v2\/posts\/3420\/revisions\/3890"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webmastersdesktop.com\/blog\/wp-json\/wp\/v2\/media\/3424"}],"wp:attachment":[{"href":"https:\/\/www.webmastersdesktop.com\/blog\/wp-json\/wp\/v2\/media?parent=3420"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webmastersdesktop.com\/blog\/wp-json\/wp\/v2\/categories?post=3420"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webmastersdesktop.com\/blog\/wp-json\/wp\/v2\/tags?post=3420"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}