bharatmakwana

Add Current Date in WordPress Post Titles

Sep 8th, 2020 (edited)
1,068
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.55 KB | None | 0 0
  1. //* Shortcode to display the current date, month and year in WordPress
  2. //* shortcode: [date_month_year]
  3. add_shortcode( 'date_month_year' , 'current_date_month_year' );
  4. function current_date_month_year() {
  5. $year = date("Y");
  6. $month = date("F");
  7. $date = date("D");
  8. return "$date, $month, $year";
  9. }
  10. add_filter( 'the_title', 'do_shortcode' ); // activate shortcode in WP Title
  11. add_filter( 'wpseo_title', 'do_shortcode' ); // activate shortcode in Yoast Title
  12. add_filter( 'wpseo_metadesc', 'do_shortcode' ); // activate shortcode in Yoast Meta Description
Add Comment
Please, Sign In to add comment