- This topic has 8 replies, 2 voices, and was last updated 4 years, 1 month ago by Tom.
-
AuthorPosts
-
March 10, 2020 at 1:42 pm #1191281Stephan
Hi guys,
i’m using GP Premium with Dispatch Theme.
With your help i was able to show image captions under my featured images, but whatever i do – i cant make it to include them in my rss feed. Thats a problem because i need to display copyright infos of my pics …
with thhe code beneath i made it to include featured images in rss-feed but the captions are missing.
could need your help with that
thanks a lot
Stephan`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, ‘full’, array( ‘style’ => ‘float:right; margin:0 0 10px 10px;’ ) );
$content = $output . $content;
}
}
return $content;
}March 10, 2020 at 5:17 pm #1191383TomLead DeveloperLead DeveloperHi there,
What code are you using to include captions? You should be able to use the same code in the filter you shared above.
Let me know ๐
March 10, 2020 at 11:25 pm #1191529StephanHi Tom,
i found this snippet, but it doesnt work – maybe you can give me a tip…
function featuredtoRSS($content) { global $post; if ( has_post_thumbnail( $post->ID ) ){ $content = '<div>' . get_the_post_thumbnail( $post->ID, 'medium', array( 'style' => 'margin-bottom: 15px;' ) ) . '</div>' . $content; $content = '<div>' . get_the_post_thumbnail_caption( $post->ID ) . '</div>' . $content; } return $content; }
March 11, 2020 at 8:17 am #1192052TomLead DeveloperLead DeveloperCan you share the full function you’re currently using to add featured images to the feed?
March 11, 2020 at 8:28 am #1192066StephanHi Tom,
its just this snippet:
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;’ ) );
$content = $output . $content;
}
}
return $content;
}March 11, 2020 at 8:36 am #1192072Stephanadd_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;' ) ); $content = $output . $content; } } return $content; }
March 11, 2020 at 4:37 pm #1192398TomLead DeveloperLead DeveloperWhat if you do this?:
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 .= '<div>' . get_the_post_thumbnail_caption( $post->ID ) . '</div>'; $content = $output . $content; } } return $content; }
March 11, 2020 at 11:02 pm #1192498StephanTom, you are a real genius – that was the solution
thanks a lot!!
March 12, 2020 at 8:22 am #1193040TomLead DeveloperLead DeveloperYou’re welcome ๐
-
AuthorPosts
- You must be logged in to reply to this topic.