It’s easy to add your own dashboard widget to WordPress, and one of the easiest to widgets to add is one that displays recent updates from any RSS feed. I put together the above widget for a project I am working on so we can promote Lawyerist posts to users.

Here’s what goes into the theme’s functions.php (or custom_functions.php, in the case of Thesis) file:

function dashboard_widget_function() {
     $rss = fetch_feed( "" );

     if ( is_wp_error($rss) ) {
          if ( is_admin() || current_user_can( 'manage_options' ) ) {
               echo '<p>';
               printf( __( '<strong>RSS Error</strong>: %s' ), $rss->get_error_message() );
               echo '</p>';

if ( !$rss->get_item_quantity() ) {
     echo '<p>Apparently, there are no updates to show!</p>';

echo "<ul>\n";

if ( !isset($items) )
     $items = 5;

     foreach ( $rss->get_items( 0, $items ) as $item ) {
          $publisher = '';
          $site_link = '';
          $link = '';
          $content = '';
          $date = '';
          $link = esc_url( strip_tags( $item->get_link() ) );
          $title = esc_html( $item->get_title() );
          $content = $item->get_content();
          $content = wp_html_excerpt( $content, 250 ) . ' ...';

         echo "<li><a class='rsswidget' href='$link'>$title</a>\n<div class='rssSummary'>$content</div>\n";

echo "</ul>\n";

function add_dashboard_widget() {
     wp_add_dashboard_widget( 'lawyerist_dashboard_widget', 'Recent Posts from', 'dashboard_widget_function' );

add_action( 'wp_dashboard_setup', 'add_dashboard_widget' );

Note that there are two different functions:

  1. dashboard_widget_function defines the actual widget
  2. add_dashboard_widget adds your widget to the dashboard and gives it an id (lawyerist_dashboard_widget, in this case) and title (“Recent Posts from”)

To change the feed, change the URI in this line:

$rss = fetch_feed( "" );

To change the id for the widget and the title that displays to users, change this line:

wp_add_dashboard_widget( 'lawyerist_dashboard_widget', 'Recent Posts from', 'lawyerist_dashboard_widget_function' );

And that’s it. You’re done!

Published by Sam Glover

Sam Glover is a lawyer and the founder and Editor in Chief of He also works with lawyers on motion practice and appeals, and is President of the board of directors of HOME Line, a nonprofit Minnesota tenant advocacy organization.

Join the Conversation


  1. Hi,

    I just used your code to create a dashboard widget that appears on all the blogs in a Multisite Network, with the feed coming from a category on the main blog.

    While setting it up, I created a “twst post.” The spelling was unintentional, so I went back and edited the post by changing the title, the slug, and the content.

    If I click on the title, it takes me to the correct post, but even after refreshing all the dashboards where the feed appears, or reloading the browser, the feed title still shows “Twst Post” and I cannot figure out how to update the display title.

    Any advice?

    1. Since the widget is powered by an RSS feed, check the feed to see if the title is still showing up wrong on the feed.

      My guess is that your feed hasn’t yet picked up the updated title. It should, eventually, but I’m not sure how quickly feeds get updated.

      1. It is showing up properly in the feed at but the dashboard widget is still showing “twst blog” as the title of the first item.

        Does the feed store items somewhere? Clicking on that link sends readers to the new post, since the old one was relegated to the trash. I had changed the title to this title, but the slug is different. The new one has a dash two added as a suffix since there was already a post of the same name.

        The behavior seems a bit weird to me.

        1. That does seem like weird behavior. You are sure it’s not a browser cache issue?

          I notice you have a FeedBurner feed, too. Might want to try that, instead.

          1. I didn’t include it as a Feedburner feed as I am using it to send notices to admins in my multisite network. The feed you are seeing is for a blog used as a template when sites are replicated.

            I also went to my database using PHP My Admin and searched for the exact phrase twst post. Nothing.

            It’s a mystery Sam, it am.

  2. Sam, many thanks for sharing this code. Eventually I’ll build a proper plugin to add this and several other things to the WP dashboard, but for now this really helped.

  3. Nice article ! but I need a plugin or code that could show rss feed of multi sites . I am having a network of sites and want to show rss feed on the main site . Is there any way to do so ? Can we add multi rss feed url in the above code or something . Please let me know about it .So much thanks to you.

    Silent Sunny

    1. You can use any RSS feed by changing this line:

      $rss = fetch_feed( "" );

      So if you want a to build a widget that displays posts from across a WordPress Multisite network, first you need a feed of all the posts. I’ve used WPMU Dev’s Recent Global Posts Feed plugin before, and it works great. (There may be free plugins that do the same thing.)

Leave a comment

Your email address will not be published. Required fields are marked *