我没办法wp_widget_rss_output
显示内容而不剥离HTML标记。参考问题(&A);A的:
但是,使用函数
fetch_feed
我们可以获取完整的提要内容。同时检查
SimplePie 函数引用。详情请参见备注:
<?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>";
}
参考问题(&A);A的: