Hi,
I have a template where I want to output a external RSS feed, but i’m having some problems as this is the first time i do this.
Outputing <title>
, <description>
, <link>
works fine. But I can’t manage to echo out the content of fields like <g:price>, <g:image_link>, <g:google_product_category>
etc. Is this something someone could help me solve?
This is my code:
<?php if(function_exists('fetch_feed')) {
include_once(ABSPATH . WPINC . '/feed.php'); // include the required file
$feed = fetch_feed('http://linktofeed/'); // specify the source feed
$limit = $feed->get_item_quantity(); // specify number of items
$items = $feed->get_items(0, $limit); // create an array of items
} ?>
<div class="partner-product-grid">
<h2>Erbjudanden</h2>
<div class="row">
<?php if ($limit == 0) { ?>
<p>Feed is empty</p>
<?php } else { foreach ($items as $item) : ?>
<div class="small-12 medium-6 large-4 columns end">
<a href="<?php echo $item->get_link(); ?>" class="partner-product">
<div class="partner-product-img">
</div>
<div class="partner-product-info">
<h3 class="partner-product-title"><?php echo $item->get_title(); ?></h3>
<h4 class="partner-product-name">Modellnamn</h4>
<p class="partner-product-desc"><?php echo $item->get_description(); ?></p>
<p class="partner-product-price"><g:price><?php echo $item->price; ?></g:price><span>kr</span></p>
<div class="button partner-btn">Köp</div>
</div>
</a>
</div>
<?php endforeach; } ?>
</div>
</div>