• Home
  • About Mitch
  • Speaking
  • Articles
  • Contact
  • Home
  • About Mitch
  • Speaking
  • Articles
  • Contact

Digital Strategist

WordPress Developer

Content Creator

Unapologetic Punk

Mitch Canter

  • X
  • Bluesky
  • GitHub
  • Twitch
  • YouTube
  • LinkedIn
Tutorial

Feed Me! Bring an RSS Feed Anywhere in your Site

CMDR Mitchcraft

Reading time: 2 minutes

Many of us are guilty of running multiple blogs – we have personal blogs, work blogs, and even blogs for our pets.  If you’re like me, however, you still like to show the different sides of yourself around your different sites.  WordPress’ built in RSS Widget does a great job at bringing external feeds into your site, but what if you want a little more control?  And what if you don’t want to constrain the feed to a widget, but give it a spot of prominence in a page template?  Well, that’s where SimplePie comes in – and the best part: it’s built into WordPress.

SimplePie is a very simple (hence the name) implementation of a php script used to scrape (fetch) a feed and display its contents.

Below is a self-made modification of the RSS sample given on the codex; this is a simple start, but it allows you to modify it like a typical WordPress loop (and structures it very similarly):

<?php if(function_exists(‘fetch_feed’)) {
include_once(ABSPATH.WPINC.’/feed.php’);
$feed = fetch_feed(‘#’); // Replace the hash mark with your feed URL
$limit = $feed->get_item_quantity(3); // specify number of items to show
$items = $feed->get_items(0, $limit); // create an array of items
}
if ($limit == 0) echo ‘<div>The feed is either empty or unavailable.</div>’; // Message to show if 0 items in feed
else foreach ($items as $item) : ?>
<div class=”post”>
<a class=”rsswidget” href=”<?php echo $item->get_permalink(); ?>”
title=”<?php echo $item->get_date(‘F j Y @ g:i a’); ?>”><h2><?php echo $item->get_title(); ?></h2></a>
<p><?php echo $item->get_date(‘F j Y’); ?></p>
<div class=”entry”>
<?php echo substr($item->get_description(), 0, 100); ?> // change 100 to number of characters to show
<a class=”fullpost” href=”<?php echo $item->get_permalink(); ?>”>read more</a>
</div>
</div>
<?php endforeach; ?>

rss feeds, SimplePie, WordPress
  • Be a Uniter, Not a Divider

    Be a Uniter, Not a Divider

    Reading time: 2 minutes

    *I work in WordPress for my day job, but a reminder that my posts and thoughts are my own.* A word of advice to anyone in management – whether it’s a C-suite, mid-level manager, or even someone who just has people under them that see them as a mentor. Be someone who unites, not someone…

    WordPress
  • Getting a Favicon on your WordPress Based Site

    Getting a Favicon on your WordPress Based Site

    Reading time: 2 minutes

    A good favicon (the little icon next to your URL in the address bar) can mean the difference between a boring bookmark, or standing out in a bookmark list.  It’s also something most people don’t think about, simply because it’s such a small part of the overall presence of a site.  Here’s the thing, though: having…

    WordPress