PHP code for wordpress to show “Published Date”, “Updated Date”, “Author Name” and “Author picture” for wordpress pages and post.
<?php
// Get the post ID
$post_id = get_the_ID();
// Get the post information
$post = get_post($post_id);
// Get the author information
$author_id = $post->post_author;
$author_name = get_the_author_meta('display_name', $author_id);
$author_avatar = get_avatar($author_id, 32); // You can adjust the avatar size as needed
// Get the post dates
$published_date = get_the_date('F j, Y', $post_id);
$updated_date = get_the_modified_date('F j, Y', $post_id);
// Display the information
echo '<p>Published Date: ' . $published_date . '</p>';
echo '<p>Last Updated: ' . $updated_date . '</p>';
echo '<p>Author: ' . $author_name . '</p>';
echo '<p>Author Avatar: ' . $author_avatar . '</p>';
?>
Output
Published Date: September 25, 2019
Last Updated: November 5, 2022
Author: Prof. Fazal Rehman Shamil
Author Avatar: