Archived topic
dynamic "year" in content header
3 replies · Started by Carlo on May 4, 2019
i've previously added the following php into the snippets plugin:
function year_shortcode() {
$year = date('Y');
return $year;
}
add_shortcode('year', 'year_shortcode');
which allows me to use the shortcode [year] in my content for a dynamic year.
the only issue is if i put the [year] shortcode into my page title, it doesn't register.
is it possible to do something similar in a page title like i am doing for the content?
PS: for bonus points, can something similar be done for the seo title also? ;)
Hi there,
Try adding this PHP to your site:
add_filter( 'the_title', 'do_shortcode' );
I'm not sure if this will work for the SEO title, but it should work for your page titles.
Awesome, works in the page title.
thanks Tom
You're welcome :)