[Resolved] Share code – Show the publication and the modification post date

Home Forums Support [Resolved] Share code – Show the publication and the modification post date

Home Forums Support Share code – Show the publication and the modification post date

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #2206119
    Alessio Angeloro

    Hi guys.

    I would like to share this feature for those who want to show the published and modified date of a post with a condition.

    add_filter( 'generate_post_date_output','aa_add_to_post_date' );
    
    function aa_add_to_post_date( $output ) {
    
    	$published = get_the_date();
    
    	$modified = get_the_modified_date();
    
    	if ($published == $modified){
    
    		return 'Published on ' . $output;  
    
    	} else {
    
    		return 'Published on ' . $output . '· Updated on '.$modified; 
    
    	}
    
    }

    Have a nice day,
    Alessio

    #2206120
    Fernando
    Customer Support

    Thank you for sharing this Alessio! 🙂

    #2206125
    Alessio Angeloro

    Welcome.

    I love GP 🙂

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.