RSS仪表板小部件不显示视觉效果

时间:2013-03-16 作者:10wtaylor

我在仪表板上使用RSS提要小部件作为shown in this Q&A. 问题是feed不会显示任何像图像或视频这样的视觉效果。我通过查看我使用的原始饲料来验证这一点。下面是我的提要面板小部件的快照:
image.

我如何获得视觉效果,或者这是WordPress显示数据的方式?

1 个回复
最合适的回答,由SO网友:brasofilo 整理而成

我没办法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的:

结束