Created
February 13, 2025 12:08
-
-
Save metodiew/cce127a0dc0fa1eb2df10fffbd118e52 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class DX_RSS_Feed { | |
public function __construct() { | |
add_filter( 'the_excerpt_rss', array( $this, 'featured_image_in_rss_feed' ) ); | |
add_filter( 'the_content_feed', array( $this, 'featured_image_in_rss_feed' ) ); | |
} | |
/** | |
* Adds the post's featured image to the RSS feed | |
* | |
* @param $content | |
* | |
* @return mixed|string | |
*/ | |
function featured_image_in_rss_feed( $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; | |
} | |
return $content; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment