Shortcode not working in Jetpack Top Posts & Pages widget


I’ve added [year] shortcode to some of my posts’ titles.

I used this in functions.php to enable this shortcode:

add_shortcode( 'year' , 'current_year' );
function current_year() {
    $year = date("Y");
    return "$year";

I then added this too to enable shortcodes in widgets:

add_filter( 'widget_text', 'do_shortcode' );

But the shortcode doesn’t work in the post titles list shown by Top Posts & Pages widget by Jetpack.

How do I fix it?

heyitsritesh 2 years 2020-12-27T02:11:39-05:00 0 Answers 5 views 0

Leave an answer