Auto Updates Every Year

How to Add the Current Year in WordPress Titles

Add a {{year}} placeholder to your WordPress titles and let it auto-update every January. Keep content fresh, boost SEO, and save time effortlessly — from post titles to SEO meta titles and even browser tab text.

Small details like the year in your titles can make a big difference. Adding the current year to key titles signals that your content is relevant right now, which can improve click-through rates in search results and help build trust with readers.

The good news? You don’t need to manually edit those titles every January. With a simple {{year}} placeholder, WordPress can automatically insert the current year anywhere you want — in post titles, page titles, SEO titles, and even browser tab titles.

In this guide, we’ll show you exactly how to set it up in minutes, so your site stays fresh and your workflow stays effortless. No advanced coding skills required — just a few copy-paste snippets and you’re done.

💡 Benefits of Using a {{year}} Placeholder

  • Saves time – no more editing titles every January.
  • Boosts SEO – search engines see your content as fresh.
  • Improves CTR – up-to-date titles attract more clicks.
  • Keeps branding consistent – year updates happen automatically site-wide.

Why Show the Current Year in WordPress Titles?

Adding the current year to titles is a small tweak that can have a big impact on how your content performs. Here’s why it’s worth considering:

1. SEO Benefits

Search engines like Google favor content that appears fresh and relevant. Including the year in titles:

  • Signals that your post or page is up-to-date.
  • Can help you compete for keywords that include the year (e.g., “Best WooCommerce Shipping Plugins in 2025”).
  • Encourages better rankings for time-sensitive searches.

2. User Trust and Click-Through Rates

When visitors see a current year in your title, they’re more likely to click because they know the content is recent and maintained.

  • A title like “Top SEO Tools 2025” looks more appealing than “Top SEO Tools” when someone is searching in 2025.
  • Readers are less likely to skip over your link thinking the information is outdated.

3. Saves Time and Reduces Errors

Without automation, you’d have to manually change each title across your site every year. That’s not only time-consuming, but it’s easy to miss a few pages. A placeholder does the work for you, instantly and site-wide.

Where You Can Use the {{year}} Placeholder

Current year in WordPress title - placeholder

One of the great things about the {{year}} placeholder is its flexibility. Once you set it up, you can use it almost anywhere WordPress outputs a title or custom text. Here are the most common use cases:

Post and Page Titles

  • Ideal for blog posts that are updated regularly, like “Best WooCommerce Plugins {{year}}” or “How to Start a Blog in {{year}}.”
  • Works for both new and existing posts — no need to edit each one manually next year.

SEO Titles and Meta Descriptions

  • If you’re using plugins like Yoast SEO, Rank Math, or All in One SEO, you can use the placeholder in custom SEO title fields.
  • Example: Affordable Hosting Deals {{year}} → automatically updates in search engine results.

Document Title (Browser Tab)

  • Appears at the top of the browser window or tab.
  • Useful for reinforcing freshness even when users are multitasking with many open tabs.

Custom Headings or Widgets

  • If your theme or page builder (Elementor, WPBakery, etc.) allows dynamic fields, you can insert the placeholder in headings, banners, or sidebar widgets.

Category or Tag Descriptions

  • Helpful for seasonal categories like “Black Friday Deals {{year}}” or “Summer Trends {{year}}.”

How the {{year}} Placeholder Works

The {{year}} placeholder is simply a piece of text in your title or content that gets swapped out for the current year when the page is displayed. WordPress doesn’t have a built-in placeholder for this, but we can easily add it using filters.

When WordPress outputs a title, SEO title, document title, or post content, it passes the text through a filter hook. This gives us a chance to detect our {{year}} marker and replace it with the actual year using PHP’s date() or WordPress’s date_i18n() function.

Example flow:

  1. You create a post titled: WordPress Plugins {{year}}
  2. WordPress calls a filter like the_title before showing it on the site.
  3. Our custom code runs, finds {{year}}, and replaces it with the current year.
  4. On the front-end, visitors see: Best WordPress Plugins 2025
  5. Next year, without changing the title in the editor, it will show 2026.

This approach works everywhere that WordPress uses a filterable output — including post titles, content, document titles, SEO plugin titles, and more.

Tip: When you create a new post with a {{year}} placeholder in the title, WordPress will include year in the permalink (URL). Since placeholders won’t be replaced in URLs, edit the permalink manually before publishing to keep it clean and SEO-friendly.


Adding PHP code: Add custom code to your child theme’s functions.php file or use a plugin like Code Snippets to safely insert functions.

We’ll start with a small helper function that does the replacement, and then we’ll apply it to different parts of WordPress using separate filters.

DRY Helper

A tiny helper that swaps {{year}} with the current year (respects site timezone/locale). Use it in all filters below.

Note: This function is mandatory if you plan to use the snippets in the next sections. Without it, the filters will call an undefined function, which can break your site.

function devnet_replace_year($text)
{
	return is_string($text) ? str_replace('{{year}}', date_i18n('Y'), $text) : $text;
}

Post & Page Titles

Replaces in titles wherever the_title() is used. Keep the is_admin() guard if you want {{year}} visible in the editor.

add_filter('the_title', function ($title) {
	if (is_admin()) return $title; // optional
	return devnet_replace_year($title);
}, 10, 1);

Post Content

Use when you want the year inside the article body to update automatically.

add_filter('the_content', function ($content) {
	if (is_admin()) return $content; // optional
	return devnet_replace_year($content);
}, 10, 1);

Document (Browser Tab) Title — Modern Themes

Covers both full string and segmented parts for maximum compatibility.

add_filter('pre_get_document_title', function ($title) {
	return devnet_replace_year($title);
});

add_filter('document_title_parts', function ($parts) {
	foreach ($parts as $k => $part) {
		$parts[$k] = devnet_replace_year($part);
	}
	return $parts;
});

Fallback — Older Themes

Safe catch-all for themes still using deprecated wp_title().

// Fallback for older themes using wp_title() (deprecated, but harmless)
add_filter('wp_title', function ($title) {
	return devnet_replace_year($title);
});

SEO Plugin Titles

Ensures custom SEO titles also update in SERPs.

Note: If you use an SEO plugin, pick the snippet for your plugin only. You don’t need all three.

// Yoast SEO
add_filter('wpseo_title', function ($title) {   
	return devnet_replace_year($title);
});

// Rank Math
add_filter('rank_math/frontend/title', function ($title) {
	return devnet_replace_year($title);
});

// All in One SEO
add_filter('aioseo_title', function ($title) {
	return devnet_replace_year($title);
});

Full Code Snippet

Here’s the complete code from all sections combined, so you can copy and paste it in one go.

// Helper: replace {{year}} with current year (site timezone/locale)
function devnet_replace_year($text)
{
	return is_string($text) ? str_replace('{{year}}', date_i18n('Y'), $text) : $text;
}

// Replace {{year}} in titles
add_filter('the_title', function ($title) {
	if (is_admin()) return $title; // optional
	return devnet_replace_year($title);
}, 10, 1);

// Replace {{year}} in post content
add_filter('the_content', function ($content) {
	if (is_admin()) return $content; // optional
	return devnet_replace_year($content);
}, 10, 1);

// Browser tab title (modern themes)
add_filter('pre_get_document_title', function ($title) {
	return devnet_replace_year($title);
});
add_filter('document_title_parts', function ($parts) {
	foreach ($parts as $k => $part) {
		$parts[$k] = devnet_replace_year($part);
	}
	return $parts;
});

// Fallback for older themes using wp_title() (deprecated, but harmless)
add_filter('wp_title', function ($title) {
	return devnet_replace_year($title);
});

// Yoast SEO
add_filter('wpseo_title', function ($title) {   
	return devnet_replace_year($title);
});

// Rank Math
add_filter('rank_math/frontend/title', function ($title) {
	return devnet_replace_year($title);
});

// All in One SEO
add_filter('aioseo_title', function ($title) {
	return devnet_replace_year($title);
});

Best Practices

  • Use where freshness matters – Ideal for posts like “Best WordPress Plugins {{year}}” or seasonal guides. Use for roundups, trend posts, seasonal pages — anywhere the year signals relevance.
  • Avoid keyword stuffing – Adding the year to every title can look spammy in search results.
  • Test after adding – Check a few posts and pages on the front-end to confirm {{year}} is replaced everywhere you expect.
  • Mind your SEO plugin – Only use the snippet for the SEO plugin you have active.
  • Clear caches – After adding the code, purge your site and CDN caches so updates are visible immediately.

Common Issues & Fixes

{{year}} still shows in the title

  • Check if your theme or plugin outputs a custom field instead of the standard WordPress title functions.
  • Make sure the correct snippet (e.g., for your SEO plugin) is active.

Changes not visible

  • Clear your site cache, CDN cache, and browser cache.
  • If you use a caching plugin, purge all pages.

Placeholder also replaced in the admin/editor

  • Add the is_admin() check in the snippet to keep {{year}} visible in wp-admin.

Errors after adding code

  • Make sure the devnet_replace_year() helper function is in place before any snippet that calls it. Without it, your site will throw a fatal error.

Final Thoughts

A simple {{year}} placeholder can save you time, keep your content looking fresh, and improve click-through rates in search results. Once the helper function is in place, you can apply it to post titles, content, browser tabs, and SEO titles with just a few filters.

Start by adding it to the areas where the year really matters — like annual round-ups, seasonal posts, or “best of” guides — and let WordPress handle the updates for you every January.

Small automation, big impact.

Share this:
devnet symbol

Devnet - web development

We specialize in creating custom WordPress and WooCommerce websites and online stores. From custom plugins and integrations to custom design and user experience, we have the expertise to bring your vision to life. We also offer ongoing support and maintenance services to ensure the smooth operation of your website.
Feel free to reach out to us – we look forward to hearing from you.