Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render thumbnail #2

Open
cornelyus opened this issue May 3, 2022 · 0 comments
Open

Render thumbnail #2

cornelyus opened this issue May 3, 2022 · 0 comments

Comments

@cornelyus
Copy link

cornelyus commented May 3, 2022

Hi,
Thanks for the plugin..

It's working great, but I was in the need to also print the thumbnail of the post.
Was looking for how to do this, and found this code for using on our theme functions.php

function rss_post_thumbnail($content) {
global $post;
if(has_post_thumbnail($post->ID)) {
$content = '<p>' . get_the_post_thumbnail($post->ID) .
'</p>' . get_the_content();
}
return $content;
}
add_filter('the_excerpt_rss', 'rss_post_thumbnail');
add_filter('the_content_feed', 'rss_post_thumbnail');

It works for the "general" feed of the website, but for the popular posts feed the thumbnail image is rendered always the same one, from the last published post.

I believe that it concerns the line "global $post;" line that gets the latest post, not the other being used on the loop..

Have any suggestion how could it also render the post thumbnail?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant