- This topic has 8 replies, 2 voices, and was last updated 1 year, 1 month ago by
Tom.
-
AuthorPosts
-
March 10, 2020 at 1:42 pm #1191281
Stephan
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 #1191383Tom
Lead 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 π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 10, 2020 at 11:25 pm #1191529Stephan
Hi 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 #1192052Tom
Lead DeveloperLead DeveloperCan you share the full function you’re currently using to add featured images to the feed?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 11, 2020 at 8:28 am #1192066Stephan
Hi 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 #1192072Stephan
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 4:37 pm #1192398Tom
Lead 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; }
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 11, 2020 at 11:02 pm #1192498Stephan
Tom, you are a real genius – that was the solution
thanks a lot!!
March 12, 2020 at 8:22 am #1193040Tom
Lead DeveloperLead DeveloperYou’re welcome π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.