Blank WP.blogspot.com

Show Any RSS Feed on Your WordPress Weblog

 Show Any RSS Feed on Your WordPress Weblog

There are occasions whenever you wish to show exterior RSS feed in your weblog. Maybe a weblog feed of your one other weblog or another web site. Nicely you do not want a plugin to do that as a result of WordPress have a operate in-built that can maintain this. On this article we'll present you how one can show an exterior RSS feed in your weblog. This manner you possibly can even use WordPress as a information aggregator.

Merely paste the next code in any WordPress file that you just select. Preferrably in a custom page that you just create.

<h2><?php _e( 'Latest information from Some-Different Weblog:', 'my-text-domain' ); ?></h2>

<?php // Get RSS Feed(s)
include_once( ABSPATH . WPINC . '/feed.php' );

// Get a SimplePie feed object from the required feed supply.
$rss = fetch_feed( 'http://www.blankwp.com/feed/' );

if ( ! is_wp_error( $rss ) ) : // Checks that the article is created accurately

    // Determine what number of complete objects there are, however restrict it to five. 
    $maxitems = $rss->get_item_quantity( 5 ); 

    // Construct an array of all of the objects, beginning with aspect zero (first aspect).
    $rss_items = $rss->get_items( zero, $maxitems );

endif;
?>

<ul>
    <?php if ( $maxitems == zero ) : ?>
        <li><?php _e( 'No objects', 'my-text-domain' ); ?></li>
    <?php else : ?>
        <?php // Loop by every feed merchandise and show every merchandise as a hyperlink. ?>
        <?php foreach ( $rss_items as $merchandise ) : ?>
            <li>
                <a href="<?php echo esc_url( $item->get_permalink() ); ?>"
                    title="<?php printf( __( 'Posted %s', 'my-text-domain' ), $item->get_date('j F Y | g:i a') ); ?>">
                    <?php echo esc_html( $item->get_title() ); ?>
                </a>
            </li>
        <?php endforeach; ?>
    <?php endif; ?>
</ul>

Be sure to change the feeds url and the amount and every other setting that you just like.

Supply: WordPress Codex

Tutorials