HippySunshine
Senior Member
I am trying to pull content from a job vacancy feed into a WordPress website. I've never done this before so not quite got it right. I've managed to pull in the Job Title and Published date, but I can't seem to pull anything else and It's going a little over my head.
Any info/help would be much appreciated.
This is the feed I am pulling from:
And this is the php I have in my WordPress template to pull content:
Any info/help would be much appreciated.
This is the feed I am pulling from:
HTML:
<rss xmlns:a10="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<title>RSS Feed Title</title>
<link>https://feedlink.com
<description>RSS Feed Description</description>
<item>
<link>https://feedlink/item.com</link>
<title>Item Title One</title>
<a10:updated>2019-09-19T11:53:35Z</a10:updated>
<a10:content type="text/xml">
<vacancy>
<vacancyid>019623</vacancyid>
<vtitle>Item Title One</vtitle>
<vacancypublishinfoid>1744392</vacancypublishinfoid>
<vlocation>Location</vlocation>
<vsalary>£10 ph</vsalary>
<vexpirydate>07/10/2019 23:59:00</vexpirydate>
<vmlocation>Location</vmlocation>
<vmdiscipline>Vacancy intro</vmdiscipline>
<vadvert>Main vacancy details</vadvert>
<vreference>HCGWH464286</vreference>
</vacancy>
</a10:content>
</item>
<item>
<link>https://feedlink/item.com</link>
<title>Item Title Two</title>
<a10:updated>2019-09-19T11:53:35Z</a10:updated>
<a10:content type="text/xml">
<vacancy>
<vacancyid>019623</vacancyid>
<vtitle>Item Title Two</vtitle>
<vacancypublishinfoid>1744392</vacancypublishinfoid>
<vlocation>Location</vlocation>
<vsalary>£10 ph</vsalary>
<vexpirydate>07/10/2019 23:59:00</vexpirydate>
<vmlocation>Location</vmlocation>
<vmdiscipline>Vacancy intro</vmdiscipline>
<vadvert>Main vacancy details</vadvert>
<vreference>HCGWH464286</vreference>
</vacancy>
</a10:content>
</item>
</channel>
</rss>
And this is the php I have in my WordPress template to pull content:
PHP:
<?php
include_once( ABSPATH . WPINC . '/feed.php' );
// Get a SimplePie feed object from the specified feed source.
$rss = fetch_feed( 'http://feedurl.com' );
$maxitems = 0;
if ( ! is_wp_error( $rss ) ) :
$maxitems = $rss->get_item_quantity( 3 );
$rss_items = $rss->get_items( 0, $maxitems );
endif;
?>
<ul class="list">
<?php if ( $maxitems == 0 ) : ?>
<li class="post"><?php _e( 'No current vacancies', 'my-text-domain' ); ?></li>
<?php else : ?>
<?php
foreach ( $rss_items as $item ) :
?>
<li class="post">
<div class="content-wrapper">
<div class="post-title">
<h3 class="label">Job Title:</h3> <span class="input"><?php echo $item->get_title(); ?></span>
</div>
<div class="post-description">
<h3 class="label">Job Description:</h3> <span class="input"><?php echo $item->get_description(); ?></span>
</div>
<div class="container">
<a class="apply-link btn round-btn" href="<?php echo $item->get_permalink(); ?>">Apply</a>
</div>
</div>
</li>
<?php endforeach; ?>
<?php endif; ?>
</ul>