Blog / Social Media / Custom Twitter feed without an API

Custom Twitter feed without an API

Ever since Twitter API access was shut down for applications there has been a problem showing customizable Twitter feeds on websites.

Some WordPress plugins like Custom Twitter Feeds by Smash Balloon have rolled out updates to try and fix the issue, but updates so far are for paid users leaving those that just needed the free simplified version somewhat out in the cold.

A workaround we have been using on client sites is to use RSS instead. Twitter doesn’t natively offer RSS feeds but you can use Nitter – a free service that lets you quickly look at a tweet.

Then use fetch_feed in a template to pull in the feed like so:

<?php include_once(ABSPATH . WPINC . '/rss.php');
$rss = fetch_feed('');
$maxitems = $rss->get_item_quantity(3);
$rss_items = $rss->get_items(0, $maxitems); 
<?php if ($maxitems == 0) echo '<li>No items.</li>';
// Loop through each feed item and display each item as a hyperlink.
foreach ( $rss_items as $item ) : ?>
<?php echo ''.$item->get_date('j F Y | g:i a'); ?>
<a href='<?php echo $item->get_permalink(); ?>'
title='<?php echo 'Posted '.$item->get_date('j F Y | g:i a'); ?>'>
<?php echo $item->get_title(); ?></a>
<?php endforeach; ?>

The example code above is a basic feed from github which still works fine.

Now you can display your Twitter feed in a customizable, responsive and lightweight way.