Any RSS Feed as a Dashboard Widget
Shows the latest headlines from an RSS feed of your choice on the dashboard, such as your agency blog or an industry news site.
Opens WPIDE on
Code
$wpide_feed_widget = array(
'title' => 'Latest News',
'url' => 'https://wordpress.org/news/feed/',
'items' => 5,
);
add_action( 'wp_dashboard_setup', function () use ( $wpide_feed_widget ) {
wp_add_dashboard_widget( 'wpide_rss_feed', esc_html( $wpide_feed_widget['title'] ), function () use ( $wpide_feed_widget ) {
echo '<div class="rss-widget">';
// wp_widget_rss_output() fetches the feed and caches it for 12 hours.
wp_widget_rss_output( $wpide_feed_widget['url'], array(
'items' => (int) $wpide_feed_widget['items'],
'show_summary' => 1,
'show_date' => 1,
) );
echo '</div>';
} );
} );
Notes
The feed is fetched from the remote site, then cached by WordPress.
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.