-
Hi,
I would like to add Auto Add Dynamic Year in WordPress Post Titles.
I am entering the following code in functions.php but it is not working.
//* Shortcode to display the current year in WordPress
//* shortcode: [year]add_shortcode( ‘year’ , ‘current_year’ );
function current_year() {
$year = date(“Y”);
return “$year”;
}//* Activate shortcode function in Post Title
add_filter( ‘the_title’, ‘do_shortcode’ ); // activate shortcode in WP Titlefunction my_custom_RM_title_replace_vars( $title, $id = null ) {
return RankMath\Helper::replace_vars( $title );
}
add_filter( ‘the_title’, ‘my_custom_RM_title_replace_vars’, 10, 2 );What code do I need to use instead?
The ticket ‘Auto Add Dynamic Year in WordPress Post Titles’ is closed to new replies.