- This topic has 5 replies, 2 voices, and was last updated 7 years, 7 months ago by Mahesh.
-
AuthorPosts
-
September 19, 2016 at 1:58 am #99615Marianne UndheimParticipant
I want to add the date of publication and last update on blog pages. Is that possible, and how do I do it? http://www.digitalkreativitet.no
September 19, 2016 at 1:26 pm #99649MaheshKeymaster@marianne-undheim: For this, you’ll need to create a child theme. You can find more details on creating child theme HERE. Then in your child theme’s functions.php, add the following codes:
function catchbox_posted_on_pages() { printf( __( '<span class="sep">Posted on </span><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date updated" datetime="%3$s" pubdate>%4$s</time></a>', 'catch-box' ), esc_url( get_permalink() ), esc_attr( get_the_time() ), esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ) ); }
Next copy, content-page.php file from parent theme to child theme. And add the following line:
<?php catchbox_posted_on_pages(); ?>
Just after<h1 class="entry-title"><?php the_title(); ?></h1>
line within the<header>
tag.Regards,
MaheshSeptember 19, 2016 at 2:06 pm #99651Marianne UndheimParticipantThanks for your quick answer!
September 19, 2016 at 4:46 pm #99663MaheshKeymaster@marianne-undheim: Thank you for your appreciation. Have a nice day!
Regards,
MaheshSeptember 21, 2016 at 1:21 am #99791Marianne UndheimParticipantI just managed to add the publication date on the pages. However, several of the pages have been updated afterwards. I therefore need to add the update date also. What code do I write then?
Marianne Undheim
September 21, 2016 at 1:40 pm #99818MaheshKeymaster@marianne-undheim: Add the following codes in your child theme’s
functions.php
function catchbox_modified_on_pages() { printf( __( '<span class="sep">Modified on </span><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date updated" datetime="%2$s" pubdate>%2$s</time></a>', 'catch-box' ), esc_url( get_permalink() ), esc_attr( get_the_modified_date('F j, Y') ) ); }
And
<?php echo ' '; catchbox_modified_on_pages(); ?>
just below
<?php catchbox_posted_on_pages(); ?>
Regards,
Mahesh -
AuthorPosts
- The topic ‘How to add publication date on pages’ is closed to new replies.