I’m trying to do a custom query after an rss fetch_feed
but for some reason nothing shows up. The code I’m using to fetch the feed is:
<?php // Get RSS Feed(s)
include_once( ABSPATH . WPINC . '/feed.php' );
// Get a SimplePie feed object from the specified feed source.
$rss = fetch_feed( 'http://seko.se/feed.rss?rssId=97' );
if ( ! is_wp_error( $rss ) ) : // Checks that the object is created correctly
// Figure out how many total items there are, but limit it to 3.
$maxitems = $rss->get_item_quantity( 3 );
// 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>
<div class="news-meta-rss">
<i class="fi-clock"></i><time datetime="<?php the_date('Y-m-d'); ?>"><?php the_time(get_option('date_format')); ?></time>
</div>
</li>
<?php endforeach; ?>
<?php wp_reset_query(); ?>
<?php endif; ?>
</ul>
And the query I’m trying to do after this is:
<?php
global $post;
$args = array(
'numberposts' => 2,
'post_type' => 'nyheter_cpt',
'category__not_in' => array( 157, 150 ),
);
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post);
?>
<div class="large-4 medium-6 small-12 columns">
<div class="panel">
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<?php the_excerpt(); ?>
<a href="<?php the_permalink(); ?>">Läs mer »</a>
<ul class="news-meta">
<li><i class="fi-clock"></i><time datetime="<?php the_date('Y-m-d'); ?>"><?php the_time(get_option('date_format')); ?></time></li>
<li><i class="fi-torso-female"></i><div class="author"><?php the_author(); ?></div></li>
</ul>
</div>
</div>
<?php endforeach; ?>
<?php wp_reset_query(); ?>
The query works just fine if I place it above the rss fetch_feed request, but as soon as I place it beneath it nothing shows up. Does anyone have a clue why?
The error seems to be connected to the rss url itself, if I use ‘http://seko.se/feed.rss?rssId=97‘ I can’t create new loops beneath it but if I use another url such as ‘http://www.wpbeginner.com/feed/‘ It works.
My original feed works just fine in other readers so I have no idea why it does not work in wordpress.