Monday , 25 May 2015
Home » Open Source » Wordpress » How to Display Date on WordPress Pages
How to Display Date on WordPress Pages

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.

About Rakshit Patel

I am PHP Freelancer, Rakshit Patel AKA WordPress Freelancer working as PHP Programmer India. I am here to share all my developing knowledge, quick coding techniques, quick solutions to save your time and help you guys for any issue or bug fixing. If you have any PHP, WordPress, Magento related work, please contact me. I am interested for the work.

Leave a Reply

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


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>