Looking to Build/Redesign a Website or Blog ?

To speak to Rakshit, call +91 968 704 2303

How to Display Date on WordPress Pages

Hi Friends,

In 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.

Thank You!


No Comments Yet.

Leave a Reply

Your email address will not be published.