[Resolved] Add current date to homepage & category pages

Home Forums Support [Resolved] Add current date to homepage & category pages

Home Forums Support Add current date to homepage & category pages

Viewing 3 posts - 16 through 18 (of 18 total)
  • Author
    Posts
  • #1016907
    David
    Staff
    Customer Support

    Just to be clear do you want the date in the Title meta tag found in the <head> of your site?

    #1016910
    oge

    Yes

    #1016933
    David
    Staff
    Customer Support

    You can try this filter:

    function custom_theme_titles( $titleparts ) {
        $pagetitle = $titleparts['title'];
        $date = date('l jS F Y');
        $sep = " | ";
        $titleparts['title'] = $pagetitle.$sep.$date;
        unset( $titleparts['site'] );
        return $titleparts;
    }
    add_filter( 'document_title_parts', 'custom_theme_titles', PHP_INT_MAX );

    Just to let you know Yoast used to include currentDate variables in there meta editor – there now deprecated and they advise against this practice.

Viewing 3 posts - 16 through 18 (of 18 total)
  • You must be logged in to reply to this topic.