0

Here is my code my code

I need to add 'medium' rss feed in my wordpress site but it shows the error and i added the image hereenter image description here

<?php /* Template Name: CustomPageT1 */?>

<?php get_header(); ?>
<rss version="2.0">


<h2><?php _e( 'Recent news 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 specified feed source.
    $rss = fetch_feed( 'https://medium.com/feed/krishnan' );

    var_dump($rss);

    if ( ! is_wp_error( $rss ) ) : // Checks that the object is created correctly
        // Figure out how many total items there are, but limit it to 5.

        $maxitems = $rss->get_item_quantity( 5 ); 
        // Build an array of all the items, starting with element 0 (first element).
        $rss_items = $rss->get_items( 0, $maxitems );
    endif;
    ?>
    <ul>
        <?php if ( $maxitems == 0 ) : ?>
            <li><?php _e( 'No items', 'my-text-domain' ); ?></li>
        <?php else : ?>
            <?php // Loop through each feed item and display each item as a hyperlink. ?>
            <?php foreach ( $rss_items as $item ) : ?>
                <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>
<!-- .content-area -->


<?php get_sidebar(); ?>
<?php get_footer(); ?>
1
  • Please use the edit link above ( and below your question ) to add more detail about your issue, what you've tried to do to solve this issue, and any other information that may be helpful.
    – Howdy_McGee
    May 8, 2017 at 15:06

1 Answer 1

0

This is my code for rss link but its not working, help me to find the solution

include_once( ABSPATH . WPINC . '/feed.php' );
// Get a SimplePie feed object from the specified feed source.
$rss = fetch_feed( 'https://medium.com/feed/......' );
if ( ! is_wp_error( $rss ) ) : // Checks that the object is created correctly
if ( ! is_wp_error( $rss ) ) : // Checks that the object is created correctly
    // Figure out how many total items there are, but limit it to 5.

    $maxitems = $rss->get_item_quantity( 5 ); 
    // Build an array of all the items, starting with element 0 (first element).
    $rss_items = $rss->get_items( 0, $maxitems );
endif;
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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