Skip to content

Instantly share code, notes, and snippets.

@wbcomdev
Last active June 7, 2021 12:18
Show Gist options
  • Select an option

  • Save wbcomdev/05300cccaa76b6e7ed15b79a315b4dc8 to your computer and use it in GitHub Desktop.

Select an option

Save wbcomdev/05300cccaa76b6e7ed15b79a315b4dc8 to your computer and use it in GitHub Desktop.
<?php
/**
* Show post thumbnails in rss feed.
*
* @param mixed $content
* @return void
*/
function wbcom_add_thumbnail_in_rss_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;' ) );
$content = $output . $content;
}
}
return $content;
}
add_filter( 'the_content', 'wbcom_add_thumbnail_in_rss_feed' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment