Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #99615
    Marianne Undheim
    Participant

    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

    #99649
    Mahesh
    Participant

    @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,
    Mahesh

    #99651
    Marianne Undheim
    Participant

    Thanks for your quick answer!

    #99663
    Mahesh
    Participant

    @marianne-undheim: Thank you for your appreciation. Have a nice day!

    Regards,
    Mahesh

    #99791
    Marianne Undheim
    Participant

    I 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

    #99818
    Mahesh
    Participant

    @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 '&nbsp;'; catchbox_modified_on_pages(); ?>
    just below
    <?php catchbox_posted_on_pages(); ?>

    Regards,
    Mahesh

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘How to add publication date on pages’ is closed to new replies.