Different rss feeds in a single dashboard widget

Yes, @toscho is right, the url works with an array of feeds adresses. And if you have 5/6 feeds, the total of items should be 20/24.

For clear separation, I think it’s better to run the wp_widget_rss_output function n number of times, and prepare a previous array with titles and addresses and iterate through it. The scroll issue is just a matter of CSS.

add_action( 'wp_dashboard_setup', 'multiple_feeds_wpse_91027' );

function multiple_feeds_wpse_91027() 
{
     wp_add_dashboard_widget( 
        'dashboard_custom_feed', 
        'Latest News', 
        'dashboard_feed_output_wpse_91027' 
    );
}

function dashboard_feed_output_wpse_91027() 
{
    // Array with Title => Address
    $feeds = array( 
        'First Feed' => 'http://example.com/feed',
        'Second Feed' => 'http://example2.com/rss', 
        'Third Feed' => 'http://example3.com/feed/',
    );
    // Set max-height and enable scrolling
    echo '<div style="max-height:300px;overflow-y:auto">';
    foreach( $feeds as $key => $value )
    {
        echo "<h3>$key</h3>";
        wp_widget_rss_output(array(
              'url' => $value,
              'items' => 4, 
              'show_summary' => 1
         ));
    }
    echo "</div>";
}

Leave a Comment