How to Display Date on WordPress Pages


Hi Friends,

By default WordPress does not show dates on WordPress pages. There might be a case that you need to display Date on WordPress page. To display Date on WordPress page, here is the code.

Put below code in your functions.php file.

function wppage_show_date( $attr ) {
  global $post;
  if (!is_page()) {
    return "";
  $show_date_value = get_post_meta($post->ID, 'showModifiedDate', true);
  if (empty($show_date_value) || !in_array($show_date_value, array('true', '1'))) {
    return "";
  $date = sprintf( '<time class="entry-date" datetime="%1$s">%2$s</time>',
      esc_attr( get_the_date( 'c' ) ),
      esc_html( get_the_date() )
  return $date;  
add_shortcode( 'wppage-show-date', 'wppage_show_date' );

Use shortcode [wppage-show-date] in template wherever you want to display date.

Leave a Reply

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




DHgate Computers - Computers, Cell Phones & more
  • We find everbuying built in php and use css to control the style.

About Author

PHP Freelancer

PHP Freelancer I am PHP Freelancer, Rakshit Patel working as PHP Programmer India. I am here to share all my developing knowledge with you people. For Hire PHP Developer India, contact me.
Follow on twitter: @raxit4u2

Get Free Programming Tutorials:

Become a Fan

Popular Topics

Recent Posts

Most Popular

Recent Comments

Get a Free Quote
Security Question: 3 + 8 = ?