Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
VGSources
Blog

How to Display an RSS Feed in WordPress: Block and PHP Methods

Learn how to display an RSS or Atom feed in WordPress using the no-code RSS block or fetch_feed() in a theme, plugin, or shortcode.
WorldWordPress: Block and PHP Methods Length9 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The simplest way to display an RSS feed in WordPress is the core RSS block: insert /rss in the block editor, enter the feed address, and choose the number of items, dates, excerpts, and layout. If you need custom HTML, a shortcode, or a PHP template, use fetch_feed() instead. It reads RSS or Atom feeds through SimplePie, returns a WP_Error when retrieval fails, and caches results for 12 hours by default.

Choose the right WordPress RSS method

There are two supported approaches. The core RSS block is an editor-managed, no-code solution. fetch_feed() is the PHP solution for a theme or plugin when the standard block cannot produce the markup or placement you need.

As an Amazon Associate I earn from qualifying purchases.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Method Where you use it What you control Main trade-off
Core RSS block (core/rss) Block editor on a post, page, widget area, or template that accepts blocks Feed URL, item count, date and excerpt toggles, excerpt length, list or grid layout, columns, and link behavior Fast to configure, but the available controls and item limit depend on the WordPress build and editor implementation
fetch_feed() Theme PHP, plugin PHP, or a shortcode registered in PHP Markup, placement, item selection, escaping, error handling, and cache lifetime Requires PHP access and maintenance; you must safely escape every value printed from the feed

For a normal page or sidebar, start with the block. Choose PHP when the feed must match a custom component, appear inside a template, combine several feeds, or be exposed through a shortcode.

Prepare the feed and your WordPress site

Find the complete feed address

Obtain the publisher’s RSS or Atom URL before opening the editor. The address must identify the feed itself, not merely the publisher’s home page. The PHP function accepts either RSS or Atom, and the RSS block also expects a feed URL.

Know which WordPress edition you are configuring

Self-hosted WordPress and WordPress.com do not always expose identical block limits. WordPress.com’s support documentation describes a maximum of 10 items for its RSS block. That cap may not apply to a self-hosted installation, so check the settings panel on the exact site and WordPress version you are editing.

Decide where the feed belongs

  • Use a page or post block when the feed is part of an article or resource page.
  • Use a widget or block-based template area when it should appear site-wide in a sidebar or footer.
  • Use a theme template, plugin, or shortcode when the feed belongs inside a custom PHP component.

Display the feed with the core RSS block

The block is named core/rss and is in the Widgets category. It is dynamic: WordPress renders the feed on the server rather than saving the feed’s generated HTML in the post content. That keeps the editor content separate from the remote items.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

1. Insert the RSS block

  1. Open the post, page, widget area, or block-based template where the feed should appear.
  2. Click the inserter, or place the cursor in a new block and type /rss.
  3. Select the RSS block from the results.
  4. Enter the complete RSS or Atom feed URL and submit it.

After the URL is accepted, the editor loads a preview. If the preview does not populate, verify the address before changing design settings; layout controls cannot repair an incorrect feed URL.

2. Set how many items appear

Open the block settings panel and adjust the item count. The developer reference lists itemsToShow with a default of 5. A different number may be displayed by the editor on another WordPress release, so treat the value shown in your site’s panel as authoritative. On WordPress.com, the support documentation describes an upper limit of 10 items.

3. Turn dates and excerpts on or off

The block exposes separate toggles for displaying each item’s date and excerpt. The developer reference lists both displayDate and displayExcerpt as false by default, meaning a fresh block normally shows titles and links without either field.

The excerpt-length control appears only after you enable excerpts. The user documentation specifies a minimum excerpt length of 10 words. The developer reference lists excerptLength with a default of 55, but the visible value can vary with the WordPress version, so confirm it in the panel before publishing.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

4. Choose list or grid presentation

Use the block’s layout controls to show items as a conventional list or as a grid. Grid mode exposes a columns setting. The underlying attributes are blockLayout and columns; the exact controls and responsive behavior are determined by the target WordPress build and theme.

5. Configure link behavior

Link-related attributes include openInNewTab and rel. Decide whether feed links should open a new tab and, if so, set the relationship value required by your site’s linking policy. Preview the block at the page width your visitors use, because a multi-column grid can become difficult to scan on narrow screens.

6. Save and test the published page

  1. Save a draft and inspect the block preview.
  2. Publish or update the page.
  3. Open the public URL in a logged-out window.
  4. Follow one item link and confirm that the title, date, and excerpt presentation match your settings.

Because the block is server-rendered, the feed markup is not stored in the post body. Keep the feed URL accurate and revisit the block settings if a WordPress update changes the controls or defaults.

Display the feed with fetch_feed()

What the function returns

fetch_feed() creates a SimplePie feed object from an RSS or Atom URL. If retrieval or parsing fails, it returns a WP_Error object instead. Always test with is_wp_error() before calling feed methods.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The function also accepts an array of URLs. SimplePie can merge those feeds into one object, which is useful when one component should present items from several sources. Merging does not remove the need to validate the URLs and handle a failed request.

A minimal theme or plugin example

The following pattern requests the example feed, takes five items, and prints a title link for each item. It is an illustrative template: place it in PHP that runs in your theme or plugin, not in the visual block editor.

$feed = fetch_feed( 'https://example.com/feed/' );

if ( ! is_wp_error( $feed ) ) {
    $items = $feed->get_items( 0, 5 );

    echo '<ul>';
    foreach ( $items as $item ) {
        printf(
            '<li><a href="%s">%s</a></li>',
            esc_url( $item->get_permalink() ),
            esc_html( $item->get_title() )
        );
    }
    echo '</ul>';
}

get_items( 0, 5 ) starts at offset zero and requests five entries. Change that count to suit the component, but keep the request bounded so a large remote feed cannot create an unexpectedly long page.

Escape every value from the feed

Feed titles and permalinks are remote data. The example uses esc_url() for the link target and esc_html() for the visible title. Apply the same principle if you add dates, author names, excerpts, or other fields: escape each value for the HTML context in which it is printed. Do not echo raw feed content into a page.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Add custom markup around the items

PHP is appropriate when the list needs classes, semantic wrappers, badges, or a theme-specific structure that the core block cannot provide. Keep the data retrieval and error check separate from the markup so a failed feed does not produce malformed HTML. If you need an empty-state message, add it in the branch that runs after a successful request when no items are returned.

Expose the same output through a shortcode

Tutorials commonly wrap the retrieval loop in a shortcode so editors can place the custom feed output without editing a template file. The shortcode callback should accept a feed URL and item count only after validating or constraining those attributes, call fetch_feed(), check for WP_Error, and return a string containing escaped markup. Register the callback with WordPress’s shortcode API in a plugin or theme. Do not allow shortcode attributes to bypass URL validation or output escaping.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Understand caching and freshness

Results fetched by fetch_feed() are cached for 12 hours by default. A page can therefore continue showing the previous set of items even after the source publishes something new. This is expected behavior, not necessarily a parsing failure.

WordPress provides the wp_feed_cache_transient_lifetime filter to change that lifetime. Use the filter in a controlled way: a shorter lifetime can make a news-style component fresher but increases remote requests, while a longer lifetime reduces requests but delays updates. Choose a value appropriate to the source’s publishing cadence and your hosting limits, then document the choice for whoever maintains the site.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshoot common RSS display problems

The block will not load the feed

  • Recheck that you pasted the feed URL rather than the publisher’s normal web page URL.
  • Try the address in a browser to confirm that it is a feed document and not a redirect to unrelated content.
  • Remove and re-enter the URL in the RSS block, then save and reload the editor.
  • If you switch to PHP, inspect the result of is_wp_error( $feed ) before calling get_items().

The PHP output is empty

  • Confirm that the code runs in a theme or plugin context where fetch_feed() is available.
  • Check that the request did not return WP_Error.
  • Verify the requested item range. An offset or count that does not match the feed can produce no visible entries.
  • Keep the error branch quiet in production but log enough information during development to identify a URL or parsing problem.

New posts are not appearing immediately

First account for the 12-hour default cache used by fetch_feed(). If the update window is too long for your use case, adjust the lifetime with wp_feed_cache_transient_lifetime rather than repeatedly forcing uncached requests.

The excerpt setting is missing

In the RSS block, the excerpt-length control appears only when the display-excerpt toggle is enabled. Turn on excerpts first, then set the length. The minimum documented length is 10 words.

The item count differs between sites

Check both the WordPress edition and the block settings panel. WordPress.com’s documentation describes a 10-item maximum, while the self-hosted block may expose a different limit. The developer-reference default of five items is a default, not a guarantee that every editor build presents the same value.

The custom list contains unsafe or broken links

Review the escaping in the PHP template. Use esc_url() for every permalink and esc_html() for visible text. Apply context-appropriate escaping to any additional feed fields before printing them.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Block or PHP: a practical decision checklist

Use the core block when

  • An editor should be able to change the feed URL and presentation without touching code.
  • A standard list or grid is sufficient.
  • The page can use the controls exposed by the target WordPress build.
  • You want the feed markup kept out of saved post content through the dynamic block.

Use fetch_feed() when

  • The feed must live in a theme template or a plugin-rendered component.
  • You need custom HTML, classes, or a site-specific card design.
  • You want to expose a reusable shortcode.
  • You need to merge multiple feed URLs through SimplePie.
  • You need deliberate control over cache lifetime and PHP-side error handling.

Maintain the integration after launch

  1. Keep a record of the feed URL and the page or template that uses it.
  2. When changing the source, update the block URL or the PHP configuration rather than editing generated output.
  3. After a WordPress core or theme update, reopen the block settings and confirm the item count, excerpt, date, and layout controls still behave as expected.
  4. For PHP integrations, retain the WP_Error check and output escaping when refactoring markup.
  5. Test both a normal feed response and a failed response so the page remains valid when the remote source is unavailable.

For most sites, the core RSS block is the right first implementation: it needs no code and exposes the settings readers usually need. Move to fetch_feed() when control over markup, placement, merged sources, or cache behavior justifies maintaining PHP.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.