Odd behavior in Twenty Seventeen theme

I am not sure how to put this post in that specific section so I’ll ask it here…
I am using the 20/17 theme to create a recent posts section on the front page of a site. The recent posts section has the featured image and a few characters of the first sentence. Everything works apart from the fact that when using a featured image it only shows up in the recent posts section. If one clicks on a post and gets taken to the post page the list of other posts no longer has the featured image where it used to be which is very odd as that image should be there.

The front page of the site is the image at the bottom with the light blue recent posts area. The other two are examples of what is going on in the actual post page with the one at the top showing what happens when you place an image at the top of a post page (it turns up in the recent posts area on the post pages).

What this behavior tells me is that the featured image is not used for both recent post areas. This is really dumb!

Is there any way to correct it so that one does not have to keep adding the same image into the body of the post (which is the only way the same image will show up in the list of posts in a post page)?



The recent post section looks for a featured image of the post. If this is not present uses the first image. To not duplicate images (if I recall correctly single post shows feature image and under it the post content) the image used as thumbnail is not used in the post.
I might be mistaken but this could be the issue.

All the posts do have featured images. But some posts have only a video in the actual post itself. This is how I found out that the software does not look for the featured image when listing the recent posts in the post page itself. If it did then the same images being used as the featured image for each post on the front page of the site in the light blue section would also show up in the list of recent posts on the post page. I hope you understand the explanation.

So, either there is an error in the code or the wrong code was used by mistake to try and use the featured image on the recent posts section on the post page.

In the images I posted you will notice that the front page recent posts area (the image at the bottom with a light blue recent posts section) has a different image (which is the featured image for that post) to the first image in the actual post itself, which is the black silhouette of a female Sherlock Holmes. The first image on a post page is the one that shows up in the recent posts section on these main ‘post pages’. And it is shown in the example given above.

When creating the other posts I do remember that I had to keep using the same image for the featured image and the first image in the actual post, because otherwise the image would not populate the placeholder in the recent posts section on the post page itself. So I would have two of the same images appearing one after the other. This behavior stopped a few days ago and I did not change anything, though I have no idea if the theme updated itself without my knowledge.

The admin dashboard is showing to update ClassicPress but I have not done so yet. I will do that first and see what happens.

I understand the issue. Problem is this is a theme issue and I need to test the thingy to see why it does so.
What are you using to fetch latest posts section in that area?

For the Recent Posts section on the front page (the light blue area) I have used custom code from one of the forum members here to get the Recent Posts from the Classic Press install to appear there. If you need it I will get the code for you.

For the Recent Posts area in the post pages, that is administered directly by Classic Press. No code has been changed there.

Which makes me realize that it is the custom code that may be the issue. I had forgotten about that code!

Instead of waiting for a response from you I think you’ll prefer that I post the code anyway. Here it is (from the index.php page):

RECENT POSTS

<?php

include(‘cp-blog/wp-load.php’); // Blog path

// Get the last 'numberposts' posts
$recent_posts = wp_get_recent_posts(array(
  'numberposts' => 15,
  'post_type' => 'post',
  'post_status' => 'publish'
));

// Display them as list
echo '<ul>';

 foreach($recent_posts as $post) {
// Get the post thumbnail and echo to the left of the link
$my_img = get_the_post_thumbnail( $post['ID'], 'thumbnail' );   
  echo '<li>', $my_img, '<a href="', get_permalink($post['ID']), '">', $post['post_title'], '</a></li>';
}
echo '</ul>';  

?>

The code didn’t fully copy over as there is a div that encloses the php code - this div is a class for this section and styles the area and the ‘Recent Posts’ text (which is an h4 element). But the above within the starting and ending php tags is what actually makes this section work.

Usually custom code is a quick way to effectively do things the right way without installing crap.

Will test it and see why it conflicts with the theme (at first glance me thinks theme’s fault).

Will come back to you as soon as I have answers.

Thank you!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.