Anbarlı News XML
Google News XML sitemap generator for WordPress / WordPress icin Google News XML sitemap eklentisi
by Gürkan Anbarlı · github.com/anbarli/anbarli-news-xml · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/anbarli/anbarli-news-xml/archive/refs/heads/main.zipA lightweight WordPress Google News XML sitemap plugin for posts published in the last 48 hours.
Anbarlı News XML generates a Google News compatible sitemap at /news-sitemap.xml, with transient cache, fallback URL support, and developer hooks for post types, taxonomy filters, and time range control.
The sitemap can be submitted to Google Search Console. It helps discovery, but it does not guarantee indexing or ranking.
Quick Start
- Download or clone this repository.
- Make sure the plugin folder is named
anbarli-news-xml. - Copy the folder to
wp-content/plugins/. - Open Plugins > Installed Plugins in WordPress.
- Activate Anbarlı News XML.
- Visit Settings > Permalinks and click Save Changes if the sitemap URL returns 404.
Generated sitemap:
https://www.example.com/news-sitemap.xml
Fallback URL:
https://www.example.com/?anb_news_sitemap=1
Submit the sitemap URL in Google Search Console > Sitemaps.
Why Anbarlı News XML?
Many WordPress SEO plugins focus on full-site XML sitemaps. Anbarlı News XML focuses on one job: generating a Google News compatible sitemap for recently published posts.
It is useful when you need:
- A dedicated
/news-sitemap.xmlendpoint. - Google News publication metadata for recent posts.
- A lightweight plugin without a complex settings screen.
- A fallback URL when rewrite rules are unavailable.
- Developer filters for post types, taxonomies, and time range.
Features
- Lists posts published within the last 48 hours.
- Generates up to 1,000 URLs.
- Includes Google News publication, publication date, language, and title fields.
- Uses the
postpost type by default. - Uses a 60-second transient cache.
- Clears the cache when posts are saved, deleted, trashed, or moved between statuses.
- Provides a query-string fallback when rewrite rules are unavailable.
- Offers filters for post types, taxonomy queries, and the time window.
Requirements
- WordPress 5.0 or later.
- PHP 7.4 or later.
- Pretty permalinks are recommended for
/news-sitemap.xml.
Developer Hooks
Include Selected Categories
add_filter('anb_news_tax_query', function () {
return array(
array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => array('news', 'world'),
),
);
});
Use A Shorter Time Range
add_filter('anb_news_hours_back', function () {
return 36;
});
The value is capped at 48 hours to follow Google News sitemap rules.
Include Custom Post Types
add_filter('anb_news_post_types', function () {
return array('post', 'news');
});
Hook Reference
| Filter | Default | Expected return | Purpose |
|---|---|---|---|
anb_news_post_types |
array('post') |
array |
Controls which post types can appear in the sitemap. |
anb_news_tax_query |
array() |
array |
Adds a WordPress tax_query to include or exclude taxonomy terms. |
anb_news_hours_back |
48 |
int |
Controls the lookback window. Values are clamped between 1 and 48. |
Example Output
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
<url>
<loc>https://www.example.com/latest-news/</loc>
<news:news>
<news:publication>
<news:name>Example News</news:name>
<news:language>en</news:language>
</news:publication>
<news:publication_date>2026-09-21T10:00:00+00:00</news:publication_date>
<news:title>Latest News Headline</news:title>
</news:news>
</url>
</urlset>
Troubleshooting
news-sitemap.xml returns 404
- Make sure the plugin is active.
- Visit Settings > Permalinks and click Save Changes.
- Check whether a CDN or caching plugin cached the sitemap URL as a 404 response.
- Try the fallback URL:
/?anb_news_sitemap=1.
A post is missing from the sitemap
- The post must be published.
- The post date must be within the last 48 hours.
- The default query only includes the
postpost type. - Check custom taxonomy filters if you added
anb_news_tax_query.
Another sitemap plugin uses the same URL
Another SEO or News plugin may already generate the same endpoint. Make sure only one plugin owns /news-sitemap.xml.
Development
Run a PHP syntax check:
php -l anbarli-news-xml.php
Test both URLs on a WordPress installation:
/news-sitemap.xml
/?anb_news_sitemap=1
Roadmap
- Add automated WordPress compatibility checks.
- Add a small example XML file for validators.
- Document compatibility notes for common SEO and cache plugins.
- Consider a minimal settings screen if enough users need non-code configuration.
Contributing
Bug reports, compatibility notes, documentation improvements, and focused pull requests are welcome. See CONTRIBUTING.md.
Security
Please do not open public issues for vulnerabilities. See SECURITY.md.
License
MIT. See LICENSE for details.
Author
Gürkan Anbarlı
anbarli.com.tr