Site logo

Archived topic

Rendering a shortcode in entry-title on an archive page.

3 replies · Started by Kyle on October 17, 2021

Viewing posts 1–4 of 4

Is there a filter I can use to render a shortcode in posts on the archive page? I have a shortcode to show the current year and it works in the post title on the single page but not in the title on the archive page. I am sure it is a filter or something that I am missing. Below is my current code:

//Shortcode to add the current year into a post title
function year_shortcode () {
$year = date_i18n ('Y');
return $year;
}
add_shortcode ('year', 'year_shortcode');

add_filter( ‘the_title’, ‘do_shortcode’ );
add_filter( ‘wpseo_title’, ‘do_shortcode’ );
add_filter( ‘wpseo_metadesc’, ‘do_shortcode’ );

Thank you in advanced!

Thank you Elvin. Much Appreciated!

No problem. Glad to be of any help .:D

This archived topic is closed to new replies.