- This topic has 9 replies, 2 voices, and was last updated 3 years, 6 months ago by David.
-
AuthorPosts
-
September 11, 2020 at 8:18 am #1439524septiady
How do i add featured image in RSS? Google News doesnt show the correct image. I searched that you have to add image code in rss.
thx for the help
September 11, 2020 at 8:31 am #1439543DavidStaffCustomer SupportHi there,
maybe the code Tom provides here will help:
https://generatepress.com/forums/topic/no-image-captions-in-rss-feed/#post-1192398
September 12, 2020 at 8:57 pm #1441083septiadyi am a noob about this. where do i post this code? thank for the help. can you guide me step by step like.
element>?>?>?
September 13, 2020 at 4:30 am #1441271DavidStaffCustomer SupportSorry should have provided this article on how to add PHP:
https://docs.generatepress.com/article/adding-php/
TLDR: Options:
1. Are you using a Child Theme ? If you are then add the code into your child themes functions.php
2. If you are not using a child theme – then install the Code Snippets plugin:
https://wordpress.org/plugins/code-snippets/2.1 Dashboard > Snippets > New Snippet
2.2 Paste in the code.
2.3 Click Save and ActivateSeptember 13, 2020 at 6:09 am #1441359septiadyWP Beginenr
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’);OR TOM’S
add_filter( ‘the_content’, ‘featured_image_in_feed’ );
function featured_image_in_feed( $content ) {
global $post;
if( is_feed() ) {
if ( has_post_thumbnail( $post->ID ) ){
$output = get_the_post_thumbnail( $post->ID, ‘medium’, array( ‘style’ => ‘float:right; margin:0 0 10px 10px;’ ) );
$output .= ‘‘ . get_the_post_thumbnail_caption( $post->ID ) . ‘‘;
$content = $output . $content;
}
}
return $content;
}Alright, i do not know any coding, i found this in wpbeginner. So which code do i use? i am using generatepress read theme.
Sorry for any stupid question. Thank you
September 13, 2020 at 6:12 am #1441365DavidStaffCustomer SupportEither of WP Beginner or Toms should work. The only difference is that Toms will also output the Image Caption if one exists.
Make sure you copy the code from the original topic or the WP Beginners sites 🙂
September 18, 2020 at 12:31 am #1448160septiadySeptember 18, 2020 at 3:27 am #1448359DavidStaffCustomer SupportLeave it as the default ‘Run snippet everywhere’
September 18, 2020 at 4:27 am #1448429septiadypriority is 10?
thank you man, generatepress has awesome support^^
September 18, 2020 at 5:02 am #1448485DavidStaffCustomer SupportYes, priority can be left at 10
-
AuthorPosts
- You must be logged in to reply to this topic.