Counting all posts on a Joomla website from an external app can be simple for some sites, but tricky for others due to varying configurations, templates, and security settings. Here’s a complete guide to the options, methods, and caveats for programmatically fetching the total post count from Joomla-powered sites.
1. Using Joomla’s RSS/Atom Feeds
- How: Many Joomla sites publish an RSS or Atom feed of their articles, usually at URLs like:
https://example.com/index.php?format=feed&type=rss
https://example.com/index.php?option=com_content&view=category&layout=blog&id=0&format=feed
- Or, more simply:
https://example.com/feed
- Pros: Quick, doesn’t require authentication.
- Cons: Most feeds show only the latest N articles (commonly 10–20). You cannot get the total count unless the feed includes a
<totalResults>
or similar tag (rare for Joomla). - How to use:
- Fetch the feed via HTTP.
- Parse the XML.
- If the feed is paginated (has “next” links), iterate over all pages and sum articles. Most Joomla feeds are not paginated.
2. Sitemap Analysis
- How: Many Joomla sites use sitemap plugins (like OSMap or JSitemap), generating an XML sitemap (
/sitemap.xml
). - Pros: Sitemaps often include all articles/posts URLs.
- Cons: Not all sites have sitemaps or may restrict access.
- How to use:
- Fetch
/sitemap.xml
or search forsitemap.xml
inrobots.txt
. - Parse and count URLs corresponding to articles (usually under
/article/
,/news/
, etc.).
- Fetch
3. Joomla API (if enabled)
- How: Modern Joomla (4.x+) offers a web API (
/api/index.php/v1/content/articles
) if enabled. - Pros: Official, structured, can return post counts or paginated lists.
- Cons: API may be disabled, require authentication, or restricted by CORS.
- How to use:
- Call:
GET https://example.com/api/index.php/v1/content/articles
- Look for a
total
or similar field in the response. - Handle pagination: Some APIs return the total, others require you to iterate.
- Call:
4. HTML Scraping
- How: Scrape the website’s blog or news index page.
- Pros: Works where no feed/API is present.
- Cons: Fragile—depends on site’s template; changes can break your code.
- How to use:
- Request the articles listing page (
/blog
,/news
, etc.). - Parse the HTML to detect total count (some sites display “Showing X of Y articles”).
- If not, scrape all paginated pages and count articles manually.
- Request the articles listing page (
5. Database Access or Custom Extension
- How: Ask the site owner to provide an endpoint or run a custom extension/plugin.
- Pros: 100% accurate.
- Cons: Only possible if you control the site or have an arrangement with the owner.
- How to use:
- Site owner installs a small plugin that exposes post count via a custom endpoint.
- Or, provides periodic post counts via API or email.
6. Third-party Plugins/Analytics
- How: Some plugins (e.g., “Article Counts”, “SP Page Builder”, etc.) may expose statistics publicly.
- How to use: Check if such a plugin is installed and exposes a public stats page or API.
7. Indirect Methods
- Search Engines: Sometimes you can estimate article count by searching
site:example.com
and restricting to “news” or “blog” URLs, but this is unreliable and often inaccurate.
Best Practices & Considerations
- Respect robots.txt: Always check if scraping or crawling is allowed.
- Handle Pagination: If fetching from APIs or feeds, handle pagination to avoid missing articles.
- Respect Rate Limits: Don’t hammer the site with requests; add delays if scraping.
- Expect Security Blocks: Some sites use firewalls (like mod_security), CAPTCHAs, or block non-browser user agents.
- User-Agent: Set a polite user-agent string identifying your app.
- Fallbacks: If one method fails (e.g., API/Feed disabled), try the next.
Summary Table
Method | Accuracy | Reliability | Requires Auth | Bypass Limits? | Notes |
---|---|---|---|---|---|
RSS/Atom Feed | Low-Med | Med-High | Rarely | No | Good for recent posts only |
Sitemap | High | Med | No | No | Best if available |
Joomla API | High | Low-Med | Often | No | Only on modern, open APIs |
HTML Scraping | Med | Med-Low | No | Maybe | Fragile, template-dependent |
DB/Custom Plugin | High | High | Yes | Yes | Only with owner permission |
3rd-party Plugins | High | Low | Sometimes | No | If stats page/API is public |
Search Engine | Low | Low | No | No | Very rough estimate |
Example: Pseudocode for All Methods
function fetchJoomlaPostCount($url) {
// 1. Try API
$apiUrl = $url . '/api/index.php/v1/content/articles';
$apiRes = fetchApi($apiUrl);
if ($apiRes && isset($apiRes['total'])) return $apiRes['total'];
// 2. Try RSS Feed
$feedUrl = $url . '/index.php?format=feed&type=rss';
$feed = fetchFeed($feedUrl);
if ($feed && isset($feed['totalResults'])) return $feed['totalResults'];
// ...or iterate paginated feeds (if present)
// 3. Try Sitemap
$sitemapUrl = $url . '/sitemap.xml';
$sitemapCount = countArticlesInSitemap($sitemapUrl);
if ($sitemapCount) return $sitemapCount;
// 4. Try HTML Scraping
$listPageUrl = $url . '/blog'; // or news, articles, etc.
$htmlCount = scrapeArticleCount($listPageUrl);
if ($htmlCount) return $htmlCount;
// 5. All failed
return null;
}
TL;DR
- Best case: Use Joomla API or sitemap.
- Fallback: RSS feed, then HTML scraping.
- Worst case: No way to get accurate count if the site is locked down.

I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I am working at Cotocus. I blog tech insights at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at I reviewed , and SEO strategies at Wizbrand.
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at PINTEREST
Rajesh Kumar at QUORA
Rajesh Kumar at WIZBRAND