Latest Tech and Tips

How to Display Any RSS Feed on Your WordPress Blog


There are occasions while you need to show exterior RSS feed on your weblog. Perhaps a weblog feed of your one other weblog or another website. Well you do not want a plugin to do that as a result of WordPress have a perform in-built that may handle this. In this text we’ll present you how one can show an exterior RSS feed on your weblog. This manner you’ll be able to even use WordPress as a information aggregator.

Simply paste the next code in any WordPress file that you just select. Preferrably in a customized web page that you just create.

<h2><?php _e( 'Recent information from Some-Other Blog:', '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( '' );

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

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

    // Build an array of all of the objects, beginning with component 0 (first component).
    $rss_items = $rss->get_items( 0, $maxitems );


    <?php if ( $maxitems == 0 ) : ?>
        <li><?php _e( 'No objects', 'my-text-domain' ); ?></li>
    <?php else : ?>
        <?php // Loop by way of every feed merchandise and show every merchandise as a hyperlink. ?>
        <?php foreach ( $rss_items as $merchandise ) : ?>
                <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() ); ?>
        <?php endforeach; ?>
    <?php endif; ?>

Make positive you modify the feeds url and the amount and some other setting that you just like.

Source: WordPress Codex