Hello,
I have a page that should display the latest blog post. The layout should therefore be the same as the blog posts. I have duplicated the template for single blog posts and assigned it to this page. I placed a widget in the contents of the page to retrieve the latest blog post.
It does display a different layout than regular pages, but it is still different from a blog post:
The date is not correct
The name of the author is not correct. Important to know: in a blog post, the name of the author is written in a separate field and retrieved by a variable.
The title is shown below the date, not above
The code behind the title – author – date part is:
<?php
the_title( ‘<div class=”blog_title”><p>’, ‘</p></div>’ );
$auth_profile_link = get_post_meta( get_the_ID(), ‘wpcf-author-profiles’, true );
{
echo ‘<div class=”blog_author2″><p>Written by ‘ . wp_kses_post( $auth_profile_link ) . ‘</p></div>’;
}
$creator_profile_link = get_post_meta( get_the_ID(), ‘wpcf-images-created’, true );
if ( ! empty( $creator_profile_link ) ) {
echo ‘<div class=”blog_creator”><p>Images created by ‘ . wp_kses_post( $creator_profile_link ) . ‘</p></div>’;
}
echo ‘<div class=”blog_date”><p>’ . get_the_date( ‘F, j Y’ ) . ‘</p></div>’;
?>
My question is:
How can I make this page https://ethicsandtechnology.eu/blog/
look the same as this one https://ethicsandtechnology.eu/blog-post/do-not-hire-a-phd-student-hire-an-illustrator-2/
Thanks in advance for any tips.
Best regards,
Thalitha
Hi Thalitha
Thanks for reaching out.
Have you made progress since posting?
Kind regards
Andrew
Dear Andrew,
Yes, I found the answer. What I wanted was a page that showed the latest blog post in the same layout as a blog post.
The problem was that I thought I needed to have the same template for blog posts as for this page. However, I called for the blog in the contents of this page. So when the template says get_title, in a blog post this would be the title of the blog, whereas in the page it was the title of the page. Hence, I didn’t get the same result.
I found my answer here. https://siteorigin.com/page-builder/bundled-widgets/post-loop-widget/
So, the template of blog posts should not be the same as the whole page, but as the loop.
I actually had to take elements away from the template of the page, as breadcrumbs, otherwise they would be shown twice.
Now the blog page blog posts are similar and visitors will hardly notice the difference.
Hopefully my search will help someone else.
Best,
Mariska
Hi Mariska
Thanks for your detailed reply. I’m glad to hear you made progress with the Post Loop Widget.
All the best with your site.
Kind regards
Andrew