Use Your Logo as the Feed Image
Shows your own logo in feed readers instead of the site icon, which is often too small or too simple for that space.
Opens WPIDE on
Code
// Full URL of the logo for feeds (empty = custom logo from the theme).
$wpide_feed_logo = '';
add_action( 'init', function () {
remove_action( 'rss2_head', 'rss2_site_icon' );
} );
add_action( 'rss2_head', function () use ( $wpide_feed_logo ) {
$url = $wpide_feed_logo;
if ( '' === $url && has_custom_logo() ) {
$url = (string) wp_get_attachment_image_url( (int) get_theme_mod( 'custom_logo' ), 'medium' );
}
if ( '' === $url ) {
return;
}
echo "<image>\n";
echo "\t<url>" . esc_url( $url ) . "</url>\n";
echo "\t<title>" . esc_html( get_bloginfo_rss( 'name' ) ) . "</title>\n";
echo "\t<link>" . esc_url( home_url( '/' ) ) . "</link>\n";
echo "</image>\n";
} );
Notes
Put the full URL of a square image of at least 144 pixels in $wpide_feed_logo, or leave it empty to use the theme's custom logo.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.