I couldn't manage to make wp_widget_rss_output
to show the content without stripping HTML tags. Reference Q&A's:
But, using the function fetch_feed
we can grab the full feed contents. Check also the SimplePie function reference. See comments for details:
<?php
/**
* Plugin Name: RSS Dashboard Widget with Images
* Version: 1.0
* Description: Display an array of feeds in a dashboard widgets displaying full content without stripping any HTML tags
* Author: Rodolfo Buaiz
* Author URI: https://wordpress.stackexchange.com/users/12615/brasofilo
* Plugin URI: https://wordpress.stackexchange.com/q/91137/12615
*
* License: GPLv2 or later
*/
add_action( 'wp_dashboard_setup', 'multiple_feeds_wpse_91137' );
function multiple_feeds_wpse_91137()
{
wp_add_dashboard_widget(
'dashboard_custom_feed',
'Latest News',
'dashboard_feed_output_wpse_91137'
);
}
function dashboard_feed_output_wpse_91137()
{
// Array with Title => Address
$feeds = array(
'CBC Canada' => 'http://rss.cbc.ca/lineup/topstories.xml',
'Valencia Spain' => 'feed://www.levante-emv.com/elementosInt/rss/39',
'WP Engineer' => 'http://wpengineer.com/feed/',
);
// Set max-height and enable scrolling
echo '<div class="rss-widget" style="max-height:300px;overflow-y:auto">';
// Iterate through feed
foreach( $feeds as $title => $url )
{
echo "<h3>$title</h3>";
// Fetch feed
$rss = fetch_feed( $url );
// Check for errors
if ( is_wp_error( $rss ) )
{
echo "error fetching: $title";
}
else
{
// Process feed items using SimplePie methods
$maxitems = $rss->get_item_quantity(4);
$rss_items = $rss->get_items(0, $maxitems);
// Nothing in the feed
if ($maxitems == 0)
{
echo 'No items.';
}
// Iterate through feed items
else
{
echo '<ul>';
foreach ( $rss_items as $item )
{
// Prepare contents
$link = $item->get_permalink();
$title = $item->get_title();
$date = $item->get_date();
$content = $item->get_content();
// Display content
echo "<li><a href='$link'>$title</a> : <small>$date</small><br />$content</li>";
}
echo '</ul>';
}
}
}
echo "</div>";
}
Reference Q&A's: