Automatic date on wordpress posts

Automatic date on wordpress posts | [date]

Wordpress Tricks

Hello techies, Today’s post is about Automatic date on WordPress posts. Because there isn’t any built-in function for a date, Many new bloggers are manually changing dates or set only that date of release. So to help this the latest date will be displayed automatically.

With this trick, you can rank your post with Title and SEO Title easily and you don’t have to do this manually. If you want you can only set this on your SEO Title.

Follow the Steps for Automatic date on WordPress posts :

  • STEP 1:  Open your WordPress dashboard, In Dashboard go to Appearance->Theme Editor.

    STEP 1

  • STEP  2: On Right Side, Click on Function.php.

    STEP 2

  • STEP  3 : Scroll down and at the bottom of the page

  • STEP  4: Paste following code at end of the page.

//* shortcode: [[date]]
add_shortcode( ‘date’ , ‘current_date_month_year’ );
function current_date_month_year() {
$year = date(“Y”);
$month = date(“F”);

$day = date(“d”);
return “$day $month $year”;

//* if you want only month and year just remove $day from up.
}
add_filter( ‘the_title’, ‘do_shortcode’ );
add_filter( ‘wpseo_title’, ‘do_shortcode’ );
add_filter( ‘wpseo_metadesc’, ‘do_shortcode’ );

 

STEP 3

(In this case, i removed $day)

  • STEP  5: Click on “Update File” button.

    Automatic date on wordpress posts

  • STEP  6: Now to use this function in Title and SEO Title, You just have to use the shortcode “[[date]]”.

    Automatic date on wordpress posts

  • STEP  7: Screenshots Examples.

    Automatic date on wordpress posts

2 thoughts on “Automatic date on wordpress posts | [date]

Leave a Reply

Your email address will not be published. Required fields are marked *