Bernard Aybouts - Blog - Miltonmarketing.com

Approx. read time: 3.2 min.

Post: Dynamic WordPress: Displaying Current Year with PHP Code

📘 Displaying the Current Year in WordPress (Without Hardcoding!)

Why It Matters:

Using dynamic dates (like the current year) ensures your copyright footers and date-based references stay up to date automatically—boosting professionalism and reducing manual updates.


✅ Method 1: Using functions.php (Safe Theme-Based Method)

👨‍💻 Step-by-Step:

  1. Access Your Theme’s functions.php File:

    • Go to your WordPress Admin Dashboard.

    • Navigate to Appearance → Theme File Editor.

    • Click on functions.php under the active theme (usually called Theme Functions).

  2. Add This Code:

Copy to Clipboard
  1. Use the Shortcode Anywhere:

    • In posts, pages, or widgets:
      [current_year]

    • In template files (like footer.php), use:
      php echo do_shortcode('[current_year]');

⚠️ Notes:

  • This code is theme-specific. If you change themes, you’ll need to re-add it.

  • Always backup your site before editing PHP files!


✅ Method 2: Using the “Code Snippets” Plugin (Best Practice for Non-Devs)

🔧 Why This is Safer:

Using a plugin like Code Snippets lets you run PHP code without touching theme files, so changes persist even if you switch themes.

🛠 How to Do It:

  1. Install the Plugin:

    • Go to Plugins → Add New.

    • Search for Code Snippets.

    • Install and activate it.

  2. Add a New Snippet:

    • Go to Snippets → Add New.

    • Title it: Display Current Year Shortcode.

  3. Paste This Code:

Copy to Clipboard
  1. Save and Activate the Snippet.

  2. Use the Shortcode:

    • Anywhere in your post or page, insert:
      [current_year]


🔄 Use Case Examples

  • Copyright Footer:

Copy to Clipboard

In Legal Pages or Dynamic Templates:

Copy to Clipboard

Inside Widgets:

  • Add a Text Widget or use Avada’s Custom HTML Block with:

Copy to Clipboard
  • No Hardcoded Dates: Google appreciates content that’s clearly maintained. Auto-updating your year reflects recency.

  • Structured Footers: Use semantic HTML (<footer>) and microdata for site info when possible.

  • Avoid Overuse in Headings: Don’t place [current_year] in <h1> unless contextually appropriate.


🏁 Summary

Method Best For Theme-Dependent
functions.php Developers customizing a child theme ✅ Yes
Code Snippets Editors, safer plugin approach ❌ No

📌 Bonus Tip: Auto-Update Copyright Footer

If you want to combine your site name + year dynamically:

Copy to Clipboard

Use this as [site_footer] in footers or widget areas.

For privacy reasons YouTube needs your permission to be loaded. For more details, please see our Privacy Policy – Legal Disclaimer – Site Content Policy.

Related Videos:

Bernard Aybouts - Blog - Miltonmarketing.com

Related Posts:

Show Popular Posts Without Plugins

Pro PHP Security, 2nd Edition

What is a Shortcode in WordPress?

WordPress by the Numbers Facts

WordPress PayPal Donation Shortcode: Easy Buttons & Plugins

What is a Shortcode in WordPress?

Enhance WordPress: TinyMCE Buttons & Shortcode Plugins

Pro PHP Security, 2nd Edition

Maximize WordPress SEO: Posts vs Pages & Content Strategy

PHP

Behind the Screens

Introduction to JavaScript

Disable Search in WordPress

How to Update: Automatically create media_buttons for shortcode selection

Should I Choose a Hosted or Non-hosted Blogging Platform?

What is a Blog?

How to Define surcharge by country with WooCommerce

Custom WooCommerce Code for Cart Fees & Surcharges

Create a PayPal Donation Shortcode – WordPress

Redirect New Registered Users to a Specific Page – WordPress

FAQ Hacked WordPress Website

The background-color CSS property

How do I start a WordPress blog? (hosting wordpress)

How do I install plugins in WordPress?

WordPress, SEO, and Social Media Marketing

WordPress Posts vs Pages

Introduction to Python Programming Language

Change the Author Permalink Structure – WordPress

Choose your preferred blog CMS platform

Why Python is the cooler programming language

Comparing Python to other languages

Helping humans speak to the computer

The Python Standard Library Ver 3.6.5

Learn more about JavaScript Variables

Learn Code Introspection Python Programming

Learn about programming Loops in Python

Learn Partial functions Python programming

Tips and Tricks for WRITING JAVASCRIPT code

Learn about programming Functions in Python

Learn about Numpy Arrays in Python programming

CODING WITH CSS: The style attribute

Learn about Python Generators

Learn about programming Classes and Objects in Python

Python String Formatting

Introduction to JavaScript – Variables: String Interpolation

Learn List Comprehensions in Python Programming

Learn about Python Conditions

Methods of teaching programming

The Longevity Blueprint: AI-Powered Health Optimization

Current step:1AI-Human Medical Analyzer: Smarter, Personalized Health
2AI-Human Medical Analyzer: Smarter, Personalized Health

> SYS.HEALTH: AI-Human Medical Analyzer_

// Revolutionize Your Diagnostics

Experience the perfect blend of cutting-edge AI precision and expert human care. Our revolutionary analyzer turns your raw health data into personalized, actionable insights tailored just for you.

> INITIALIZING_BIOMETRIC_SCAN...

[+] DATA_INPUT

Securely upload complex health parameters, including lab bloodwork and comprehensive medical history.

[+] PROCESSING

Advanced algorithmic parsing combined with human-level oversight ensures hyper-accurate data interpretation.

[+] OUTPUT_MATRIX

Receive smarter, faster, and truly personalized care strategies to take immediate charge of your health journey.

A name/nickname is required to continue.

> TRANSLATION_MATRIX_ACTIVE...
[ LANG_EN ]
Knowledge Heals, Prevention Protects
[ LANG_HI ]
ज्ञान ठीक करता है, रोकथाम सुरक्षा करती है
[ LANG_ZH ]
知识治愈,预防保护
[ LANG_JA ]
知識は癒し、予防は守る
[ LANG_HE ]
הידע מרפא, המניעה מגנה
[ LANG_AR ]
المعرفة تُشفي، والوقاية تحمي
[ LANG_FR ]
La connaissance guérit, la prévention protège

> SYS.AUTH: Data Processing Consent_

[ AWAITING_AUTHORIZATION ] By providing consent, you allow us to process your uploaded data through our proprietary AI-Human analysis system.

  • [+] SECURE_REVIEW: This ensures your information is carefully reviewed using advanced AI technology and certified professional oversight to deliver personalized health insights.
  • [+] PRIVACY_LOCK: Your privacy is our strict priority. Your data will only be used for this specific diagnostic purpose.

> SYS.UPLOAD: Share Medical Records [OPTIONAL]_

[ USER_CONTROL_ACTIVE ] Uploading your medical records during registration is entirely optional. You can choose to bypass this step and provide data later if it suits your timeline.

You dictate the data flow: share as much or as little as you’re comfortable with, and let us guide you toward better health.

[+] FORMAT_SUPPORT

We accept all file formats, including photos, PDFs, text documents, and raw official medical data.

[+] DATA_YIELD

Increased inputs correlate with higher precision. The more info you share, the better we tailor your personalized insights.

> NEXT_STEPS: Post-Registration Protocol_

Once your registration is complete, a human specialist from our team will personally reach out to you within 3-10 business days. We will discuss your health journey and map out exactly how we can support you.

About the Author: Bernard Aybout (Virii8)

Avatar Of Bernard Aybout (Virii8)
I am a dedicated technology enthusiast with over 45 years of life experience, passionate about computers, AI, emerging technologies, and their real-world impact. As the founder of my personal blog, MiltonMarketing.com, I explore how AI, health tech, engineering, finance, and other advanced fields leverage innovation—not as a replacement for human expertise, but as a tool to enhance it. My focus is on bridging the gap between cutting-edge technology and practical applications, ensuring ethical, responsible, and transformative use across industries. MiltonMarketing.com is more than just a tech blog—it's a growing platform for expert insights. We welcome qualified writers and industry professionals from IT, AI, healthcare, engineering, HVAC, automotive, finance, and beyond to contribute their knowledge. If you have expertise to share in how AI and technology shape industries while complementing human skills, join us in driving meaningful conversations about the future of innovation. 🚀