Published date for posts displayed incorrectly on front end (shows current date)?

So this is not a theme I built, but the client handed the site over to us and I noticed that the date on the front end for all of the posts seems to show the current date instead of the date it is published. The back end is fine and is showing the published date correctly. Just not on the front end. So my first thought is that there is something wrong with the theme, but since the theme is built with Timber, I’m not sure I can easily change it since I’ve never used it before.

This is the code in single.php:

$context = Timber::get_context();
$post = Timber::query_post();
$context[‘timberPost’] = $post;
$context[‘post’] = getSinglePost(‘post’, $post->ID);
$context[‘comment_form’] = TimberHelper::get_comment_form();
$context[‘instagram’] = $instagramCachedResults;
if (post_password_required($post->ID)) {
Timber::render(‘single-password.twig’, $context);
} else {
Timber::render(array(‘single-‘ . $post->ID . ‘.twig’, ‘single-‘ .
$post->post_type . ‘.twig’, ‘single.twig’), $context);

In a file called functions–custom-posts.php I see this code:

function getSinglePost($posttype = null, $id = null)
{
if ($id != null) {
$postId = $id;
} else {
$postId = get_the_id();
}

$attachedimage = new TimberImage(get_post_thumbnail_id());
$categories = get_the_category();

// setup an array to change the post data returned
$singlePostArray = array(
‘date’ => strtotime(get_the_date()),
‘id’ => get_the_id(),
‘title’ => get_the_title(),
‘categories’ => $categories,
‘content’ => get_the_content(),
‘excerpt’ => get_the_excerpt(),
‘tags’ => get_the_tags(),
‘post_type’ => $posttype,
‘image’ => $attachedimage,
‘link’ => get_permalink(),
);
if ($posttype == ‘post’) {
$singlePostArray[‘custom’] = prepareBlogPostFields();
}

// Restores original Post Data
wp_reset_postdata();

return $singlePostArray;
}

Here is a link to the website, see how this blog post shows the current date and not the published date like it’s supposed to? It is the same for all the blog posts: https://www.chrisapappas.com/2019/02/25/oscars-best-dressed-2019/

Any help is greatly appreciated!

Read more here:: Published date for posts displayed incorrectly on front end (shows current date)?

Leave a Reply

Your email address will not be published. Required fields are marked *