Skip to content

Instantly share code, notes, and snippets.

@theukedge
Created September 14, 2013 21:31
Show Gist options
  • Save theukedge/6565836 to your computer and use it in GitHub Desktop.
Save theukedge/6565836 to your computer and use it in GitHub Desktop.
<?php
function featured_image_in_feed( $content ) {
global $post;
if( is_feed() ) {
if( has_post_thumbnail( $post->ID ) ){
$output = get_the_post_thumbnail( $post->ID, 'large', array( 'style' => 'float:right; margin: 10px;' ) );
$content = $output . $content;
}
if( has_post_format( 'gallery' ) ) {
$output = '<p>This post contains a gallery. <a href="' . get_permalink( $post->ID ) . '">View the gallery</a> on the website.</p>';
$content = $output . $content;
}
if( has_post_format( 'video' ) ) {
$output = '<p>This post contains a video. <a href="' . get_permalink( $post->ID ) . '">View the video</a> on the website.</p>';
$content = $output . $content;
}
if( has_post_format( 'audio' ) ) {
$output = '<p>This post contains some audio. <a href="' . get_permalink( $post->ID ) . '">Listen to the audio</a> on the website.</p>';
$content = $output . $content;
}
}
return $content;
}
add_filter( 'the_content', 'featured_image_in_feed' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment