How to Replace Dashboard News Feed with Another RSS Feed in WordPress

Home » Snippets » How to Replace Dashboard News Feed with Another RSS Feed in WordPress
0

Created with:

Visibility: 

public

Creator: WPTurbo Team

Customize with WPTurbo AI
X

Add Snippet To Project

New Project
Add To Existing Project

The WordPress dashboard news feed is a quick source of updates and news on WordPress. But, wouldn’t it be even more useful if you could customize this to show updates from sources that are more relevant to you or your business? This article will show you how to replace the default WordPress dashboard news feed with any RSS feed of your choice. Whether it’s industry news, tech updates, or the latest posts from your favorite blog, you can keep it all at the tip of your fingertips right inside your WordPress dashboard.

					function wpturbo_replace_dashboard_news_feed() {
    remove_meta_box( 'dashboard_primary', 'dashboard', 'side' );
    add_meta_box(
        'dashboard_custom_feed', 
        __('Custom RSS Feed', 'wpturbo'), 
        'wpturbo_custom_dashboard_rss', 
        'dashboard', 
        'side'
    );
}
add_action('wp_dashboard_setup', 'wpturbo_replace_dashboard_news_feed');

function wpturbo_custom_dashboard_rss() {
    echo '<div class="rss-widget">';
       wp_widget_rss_output(array(
            'url' => 'https://your-rss-feed-url.com',
            'title' => __('Custom RSS Feed', 'wpturbo'),
            'items' => 3,
            'show_summary' => 1,
            'show_author' => 0,
            'show_date' => 1
       ));
    echo '</div>';
}
				

The presented code snippet is used to replace the default WordPress dashboard news feed with another RSS feed of your choice. The function wpturbo_replace_dashboard_news_feed() is responsible for removing the existing news feed and adding a new one.

Let’s look deeper into each part of this function.

remove_meta_box( 'dashboard_primary', 'dashboard', 'side' );

Here, the remove_meta_box function removes the default WordPress dashboard news feed, which is located on the side and identified by dashboard_primary. This prepares the dashboard for a new feed.

The code then proceeds to add a new custom feed.

add_meta_box(
    'dashboard_custom_feed', 
    __('Custom RSS Feed', 'wpturbo'), 
    'wpturbo_custom_dashboard_rss', 
    'dashboard', 
    'side'
);

The add_meta_box function is used to create a new meta box on the dashboard. ‘dashboard_custom_feed’ is the HTML ‘id’ attribute of the new meta box. The string __(‘Custom RSS Feed’, ‘wpturbo’) is the title of the meta box, and the text domain ‘wpturbo’ is used for localization.

‘wpturbo_custom_dashboard_rss’ is the function to be called to display the content of the meta box. As per WordPress documentation, this function should echo its output. ‘dashboard’ refers to the location where this meta box will be displayed, while ‘side’ determines its position.

Subsequently, the wpturbo_replace_dashboard_news_feed() function is added to the wp_dashboard_setup action hook, which triggers our code when the dashboard widgets are being set up.

Next, we have the wpturbo_custom_dashboard_rss() function which displays the content for our new RSS feed box on the dashboard.

echo '<div class="rss-widget">';
   wp_widget_rss_output(array(
        'url' => 'https://your-rss-feed-url.com',
        'title' => __('Custom RSS Feed', 'wpturbo'),
        'items' => 3,
        'show_summary' => 1,
        'show_author' => 0,
        'show_date' => 1
   ));
echo '</div>';

In this block, WordPress built-in function wp_widget_rss_output is used to fetch and display the RSS items from a provided URL with assigned parameters. The ‘items’ parameter is used to set the number of news items to display from our feed. ‘show_summary’, ‘show_author’, and ‘show_date’ are parameters that determine whether to display the summary, author, and date of each item, respectively.

Ensure to replace ‘https://your-rss-feed-url.com‘ with the URL of the RSS feed that you want to use.

By replacing ‘dashboard_primary’, ‘dashboard’, ‘side’ and ‘https://your-rss-feed-url.com‘ with your values, you can use this code to customize your WordPress dashboard by adding your preferred RSS feed.

Register an account to save your snippets or go Pro to get more features.