• pankajsihag

    (@pankajsihag)


    i want to display the current date in post title, how can i do this?? Currently i am using shortcode but it only works for single post, how can i enable this for homepage and archives (post title).

    The page I need help with: [log in to see the link]

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

    (@cybr)

    Howdy!

    I have plans to make something like this as a feature: https://github.com/sybrew/the-seo-framework/issues/140.

    Still, I recommend writing the date manually into the title — automatically updating the date of the post without changing the post can be seen as spam by search engines.

    Ignoring my warning, you can add this snippet to your site to add the current year to the title:

    // First, activate shortcode rendering in titles.
    add_filter( 'the_seo_framework_title_from_custom_field', 'apply_shortcodes' );
    
    // Register [title-year] shortcode.
    add_shortcode( 'title-year', fn() => esc_html( gmdate( 'Y' ) ) );

    (Where do I add this code?)

    Then, when you write [title-year] in your custom meta title, the front-end title will display the current year.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.