Skip to content

Instantly share code, notes, and snippets.

@robincornett
Last active August 29, 2015 14:05
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robincornett/9339ee7e23f502690792 to your computer and use it in GitHub Desktop.
Save robincornett/9339ee7e23f502690792 to your computer and use it in GitHub Desktop.
add featured image to feed (for feeds using excerpts instead of full content). Uses the thumbnail sized image, aligned left, with a margin for the email.
<?php
// you can add this to your theme's functions.php file. do not include the opening tag.
add_filter( 'the_excerpt_rss', 'rgc_add_featured_image_to_feed_excerpt', 1000, 1 );
function rgc_add_featured_image_to_feed_excerpt( $content ) {
if ( has_post_thumbnail( get_the_ID() ) ) {
$content = get_the_post_thumbnail( get_the_ID(), 'thumbnail', array( 'align' => 'left', 'style' => 'margin-right:20px;' ) ) . $content;
}
return $content;
}
*|RSSITEMS:|*
<h2 class="mc-toc-title"><a href="*|RSSITEM:URL|*" target="_blank">*|RSSITEM:TITLE|*</a></h2>
<em>By *|RSSITEM:AUTHOR|*</em><br />
*|RSSITEM:CONTENT|*<br />
*|END:RSSITEMS|*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment