RFC 5005 Feed Paging and Archives, and How to Read a WordPress Feed Past Its First Page
A feed is a window on the newest items. Subscribe to a WordPress site and you get the last 10 posts by default, or whatever the site owner set. Everything older is invisible to your reader, even though the site still serves it. RFC 5005, Feed Paging and Archiving, has described how to fix that since September 2007. It's a Proposed Standard, and the readers checked for this post ignore it. Below is what it defines and how close WordPress and Hugo come to it, with code to walk a feed's history today.
Three kinds of feed
RFC 5005 sorts feeds into three types and gives each its own markers.
| Type | What it means | Markers |
|---|---|---|
| Complete | The document holds every entry of the feed | <fh:complete/> in the feed head |
| Paged | A chain of documents, linked like search results | first, last, previous, next links |
| Archived | Stable documents that can rebuild the whole feed | prev-archive, next-archive, current links and <fh:archive/> |
The fh prefix maps to the namespace http://purl.org/syndication/history/1.0.
A complete feed is for lists that get replaced, like a top-10 chart. The spec says "any entry not actually in the feed document SHOULD NOT be considered part of that feed," so a reader that honors it drops old entries on refresh instead of piling them up.
Paged feeds are the cheap option. A page carries a link like this:
<link rel="next" href="http://example.org/index.atom?page=2"/>
The spec is honest about their weakness: "Paged feeds are lossy." Entries can be added or changed while a client reads the pages, and clients "SHOULD NOT present paged feeds as coherent or complete."
Archived feeds are the careful option. The subscription document holds the newest entries and links back with prev-archive. Each archive document is marked <fh:archive/>, points to the subscription feed with rel="current", and should stay the same over time: "The set of entries contained in an archive document published at a particular URI SHOULD NOT change over time." A client walks prev-archive links back until it hits one it has already read, so after the first full walk it only fetches what's new.
The RFC is written for Atom but says the extensions "are also useful in similar formats," and Appendix B shows RSS 2.0 examples using atom:link. For RSS, two items are duplicates when they have the same guid.
What WordPress does
WordPress feeds already page. They just don't say so. In WP_Query, a feed request swaps posts_per_page for the posts_per_rss option (default 10 in schema.php) and keeps paging on, so ?paged=2 turns into a SQL LIMIT with an offset. The feed template prints a rel="self" link and nothing else. No next, no last.
Tested on December 4 against pxef.com, one of the network's WordPress sites:
| Request | Status | Items | Oldest item |
|---|---|---|---|
/feed/ | 200 | 100 | Feb 10, 2023 |
/feed/?paged=2 | 200 | 100 | Jun 7, 2022 |
/feed/?paged=3 | 200 | 16 | Jun 6, 2022 |
/feed/?paged=4 | 404 | 0 |
Pages 1 and 2 shared no GUIDs. Past the end, WordPress answers 404 but still sends an RSS document with an empty channel and application/rss+xml. briefly.net did the same for ?paged=9999. A client has to treat both the 404 and an empty channel as the end.
Two practical snags came up. Some paged requests made within seconds of each other got 429 Too Many Requests with Retry-After: 300. And the site answered 403 to Python's default Python-urllib User-Agent while curl's got 200. A history walker needs to send a real User-Agent and honor Retry-After.
WordPress also has something close to RFC 5005 archives: date archive feeds. https://pxef.com/2022/06/feed/ returned all 44 posts from June 2022. A month that's over gets no new posts, so the URL is stable in practice. The catch is that these feeds have no prev-archive links, and they're capped by the same posts_per_rss setting, so a month with more posts than the limit comes back cut off.
What Hugo does
Hugo goes the other way. Its built-in RSS template has no paging at all, but the services.rss.limit setting defaults to -1, which means no limit. A default Hugo feed lists every regular page in the section. That's a complete feed in practice, without the fh:complete marker that would tell a reader so. A site that sets a limit to keep the file small loses its older posts from the feed, with no link to find them.
Adding paging links to WordPress
The rss2_head action runs inside <channel>, after the self link, and the atom namespace is already declared there. This snippet adds RFC 5005 paging links to every paged RSS feed, including category and tag feeds:
add_action( 'rss2_head', function () {
global $wp_query;
$page = max( 1, (int) get_query_var( 'paged' ) );
$last = (int) $wp_query->max_num_pages;
if ( $last < 2 ) {
return;
}
$self = remove_query_arg( 'paged', get_self_link() );
$links = array( 'first' => 1, 'last' => $last );
if ( $page > 1 ) {
$links['previous'] = $page - 1;
}
if ( $page < $last ) {
$links['next'] = $page + 1;
}
foreach ( $links as $rel => $n ) {
$href = 1 === $n ? $self : add_query_arg( 'paged', $n, $self );
printf( "\t<atom:link rel=\"%s\" href=\"%s\" />\n", $rel, esc_url( $href ) );
}
} );
max_num_pages is filled in for feed queries because WordPress counts found rows unless no_found_rows is set. The link logic was run in PHP 8.3 with small stand-ins for the WordPress functions, for a three-page feed, a category feed and a one-page feed. It was not tested on a live install. On page 2 of a three-page feed it prints first, last, previous pointing at /feed/ and next pointing at ?paged=3.
Walking a feed's history
This Python script follows next links when a feed has them and falls back to WordPress's ?paged=N when it doesn't. It drops repeated GUIDs, since a post published mid-walk pushes an item from page 1 onto page 2.
import sys, time, urllib.request, urllib.error
import xml.etree.ElementTree as ET
ATOM = "{http://www.w3.org/2005/Atom}"
UA = "feed-walker/1.0 (+https://example.org/contact)"
def fetch(url):
while True:
try:
req = urllib.request.Request(url, headers={"User-Agent": UA})
with urllib.request.urlopen(req, timeout=30) as r:
return r.read()
except urllib.error.HTTPError as e:
if e.code == 429:
time.sleep(int(e.headers.get("Retry-After", "60")))
continue
if e.code == 404:
return None
raise
def walk(url, max_pages=50):
seen, items = set(), []
for n in range(1, max_pages + 1):
body = fetch(url)
if body is None:
break
channel = ET.fromstring(body).find("channel")
page = channel.findall("item")
if not page:
break
for item in page:
key = item.findtext("guid") or item.findtext("link")
if key not in seen:
seen.add(key)
items.append(item)
nxt = channel.find(f"{ATOM}link[@rel='next']")
if nxt is not None:
url = nxt.get("href")
elif "/feed/" in url: # WordPress: no next link, so count pages
url = url.split("?")[0] + f"?paged={n + 1}"
else:
break
time.sleep(5)
return items
if __name__ == "__main__":
items = walk(sys.argv[1])
print(len(items), "items, oldest:", items[-1].findtext("pubDate"))
It was tested against two local servers. One served three linked pages with an item repeated across pages 1 and 2, and the script returned 7 unique items. The other mimicked WordPress, with ?paged=N, a 404 past the end and one 429 with Retry-After: 1. The script waited, retried and returned all 7 items. It's RSS only; an Atom version would read entry and id instead.
Who reads these links
Not many clients. A search of the current Miniflux and FreshRSS source, FreshRSS's bundled SimplePie included, found no reference to prev-archive, the fh namespace or next links in their feed parsers. Podlove's Paged Feeds recommendation asks podcast apps and hosting tools to adopt RFC 5005 paging but names none that have.
Syndicator doesn't either. It fetches each source's feed URL once per build and parses that one document, so it only ever sees the newest page. That fits a headline stream, and it's why the WordPress and Hugo feed URLs in feeds.json are plain /feed/ and /index.xml addresses.
If you publish a feed, adding paging links costs one hook and lets any tool that wants your history find it. If archives matter to you, monthly date feeds plus a prev-archive chain would get WordPress most of the way to the archived model, and they'd be cheap to serve with conditional GET because old months rarely change.