Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am using a RSS feeds widget on my dashboard as shown in this Q&A. Problem is feeds doesn't show up any visual like images or videos. I verified this by looking raw feeds which I used. Here is a snapshot of my feed dashboard widget:
image.

How can I get visuals or is this the way WordPress shows data?

share|improve this question
    
Taylor, try to research this site for building a Question, this way the answerer only spends time on the solution and not in the research. As you can see, I built the Answer with bits already existent here in WordPress Development ;) –  brasofilo Mar 16 '13 at 14:52
    
thanks for advice braso :) –  10wtaylor Mar 16 '13 at 16:38
add comment

1 Answer

up vote 0 down vote accepted

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: http://wordpress.stackexchange.com/users/12615/brasofilo
 * Plugin URI: http://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:

share|improve this answer
    
learnt alot,, especially from these references you provided. Thanks Braso! Code works smoothly,I have heard about simple pie and also about yahoo pipes, but never intended to use. Now I will modify further using these. –  10wtaylor Mar 16 '13 at 18:04
    
Well, I learned a lot too with this one, ain't this place cool?! ;) –  brasofilo Mar 16 '13 at 18:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.