• Resolved tea23hah

    (@tea23hah)


    Hi there,

    is there a way to display the current year in the title, not only in meta but in the post title as well?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hello!

    This piece of code will do:

    add_shortcode( 'year', function() {
    	return date('Y');
    } );
    add_filter( 'the_title', 'do_shortcode' );
    add_filter( 'the_seo_framework_title_from_custom_field', 'do_shortcode' );
    add_filter( 'the_seo_framework_title_from_generation', 'do_shortcode' );

    (Where to place filters?)

    When that code is active on your site, you can use [year] to display the year.

    Please mind that the placeholders and counters of The SEO Framework will not show or reflect the output of shortcodes; the SEO Bar is accurate, however.

    P.S. from WordPress v5.4 onward, it’s best to exchange do_shortcode with apply_shortcodes in the snippet.

    • This reply was modified 6 years, 2 months ago by Sybre Waaijer. Reason: clarity
    Thread Starter tea23hah

    (@tea23hah)

    Awesome, thanks for the quick reply!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Current Year in Title’ is closed to new replies.