[Resolved] Last Updated Date of The Posts

  • Author
    Posts
  • #15263

    Goungstar
    Participant

    Hi,

    Thanks for the brilliant work done with Puro! 🙂 I’d like to display the last updated date of the posts instead of the published date.

    I tried to follow some tutorials like this one. But it seems that the way Puro is coded isn’t the same as other themes.

    How could I replace the published date with the updated date?

    #15264

    Andrew Misplon
    Keymaster

    Hi, thanks for reaching out.

    Are you using the Puro theme as seen in this demo? https://demo.purothemes.com/puro/

    #15265

    Goungstar
    Participant

    Thanks for the quick response, Andrew!

    Yes. I didn’t change anything except for the fact that the homepage is a page, not the blog. 🙂

    #15273

    Goungstar
    Participant

    I tried to change the function.php. But it didn’t work. :/

    Is there a small tweak I can do in order to have the updated date instead of the published one?

    #15275

    Andrew Misplon
    Keymaster

    Thanks

    You can find a child theme for Puro here https://purothemes.com/documentation/puro-theme/child-theme-library/.

    Here is how to migrate settings from the parent to the child theme https://purothemes.com/customizer-settings-export-import/.

    Once your child theme is installed and activated you can try inserting the following into the child theme functions.php file:

    if ( ! function_exists( 'puro_posted_on' ) ) :
    /**
     * Prints HTML with meta information for the current post-date/time, author, comment count and categories.
     */
    function puro_posted_on() {
    
    	if ( is_sticky() && is_home() && ! is_paged() ) {
    		echo '<span class="featured-post">' . __( 'Sticky', 'puro' ) . '</span>';
    	}
    
    	if ( is_home() && siteorigin_setting( 'blog_post_date' ) || is_archive() && siteorigin_setting( 'blog_post_date' ) || is_search() && siteorigin_setting( 'blog_post_date' ) ) {
    		echo '<span class="entry-date"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark"><time class="published" datetime="' . esc_attr( get_the_date( 'c' ) ) . '">' . esc_html( get_the_modified_date() ) . '</time><time class="updated" datetime="' . esc_attr( get_the_modified_date( 'c' ) ) . '">' . esc_html( get_the_modified_date() ) . '</time></span></a>';
    	}
    
    	if ( is_single() && siteorigin_setting( 'blog_post_date' ) ) {
    		echo '<span class="entry-date"><time class="published" datetime="' . esc_attr( get_the_date( 'c' ) ) . '">' . esc_html( get_the_modified_date() ) . '</time><time class="updated" datetime="' . esc_attr( get_the_modified_date( 'c' ) ) . '">' . esc_html( get_the_modified_date() ) . '</time></span>';
    	}
    
    	if ( siteorigin_setting( 'blog_post_author' ) ) {
    		echo '<span class="byline"><span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '" rel="author">' . esc_html( get_the_author() ) . '</a></span></span>';
    	}
    
    	if ( has_category() && siteorigin_setting( 'blog_post_cats' ) ) {
    		echo '<span class="cat-links">' . get_the_category_list( __( ', ', 'puro' ) ) . '</span>';
    	}
    
    	if ( has_tag() && siteorigin_setting( 'blog_post_tags' ) ) {
    		echo '<span class="tags-links">' . get_the_tag_list( '', __( ', ', 'puro' ) ) . '</span>';
    	}
    
    	if ( comments_open() && siteorigin_setting( 'blog_post_comment_count' ) ) { 
    		echo '<span class="comments-link">';
    		comments_popup_link( __( 'Leave a comment', 'puro' ), __( '1 Comment', 'puro' ), __( '% Comments', 'puro' ) );
    		echo '</span>';
    	}
    
    }
    endif;
    #15277

    Goungstar
    Participant

    It works!! Thanks a lot, Andrew for the clear tuto. 🙂

    Puro is one of the best blogging themes I found.

    #15278

    Andrew Misplon
    Keymaster

    Super, glad to hear you’re making progress 🙂

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Last Updated Date of The Posts’ is closed to new replies.

Scroll to top