Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/jeduvalenzuela/wp-api-news-importer/archive/refs/heads/main.zipA lightweight WordPress plugin that renders news from remote WordPress REST APIs without storing them locally. Perfect for news aggregation, multi-site news feeds, and distributed content consumption.
Features
- Real-time News Rendering: Fetch and display posts from external WordPress REST APIs on-demand
- No Local Storage: News items are not stored in your database—only rendered when requested
- Multiple Sources: Configure and manage multiple news sources (domains) from the admin panel
- Flexible Filtering: Filter by source, date range, search terms, and pagination settings
- Embedded Media: Optionally include featured images and author information
- Clean URL Routing: Posts are available at
/noticias/(Spanish) or customizable endpoint - Query Parameters: Control results via URL parameters without page reloads
Installation
- Download or clone this plugin into your WordPress
wp-content/plugins/directory - Activate the plugin from the WordPress admin Plugins page
- Navigate to API Noticias (Admin → Plugins → WP API News Render menu item)
- Add one or more news sources with their WordPress REST API endpoints
Configuration
Adding a News Source
In the API Noticias admin page:
- Label: A friendly name for the source (e.g., "Cabra Noticias")
- Domain: The source domain (e.g.,
cabranoticias.com) - Base Endpoint: The full REST API endpoint (e.g.,
https://cabranoticias.com/wp-json/wp/v2/posts) - Use _embed: Enable to fetch related data (featured images, authors)
- Default Parameters: Query string parameters applied to every request (e.g.,
per_page=20&orderby=date&order=desc)
Usage
Visit /noticias/ on your site with optional query parameters:
URL Parameters
| Parameter | Example | Description |
|---|---|---|
site |
?site=cabranoticias.com |
Filter by source domain or label |
after |
?after=2025-12-05T00:00:00 |
Show posts published after this ISO date |
search |
?search=keyword |
Search posts by keyword |
per_page |
?per_page=50 |
Results per page (1–100, default: 20) |
max_pages |
?max_pages=5 |
Maximum pages to fetch per source (default: 3) |
status |
?status=publish |
Post status filter (default: publish) |
orderby |
?orderby=date |
Order by field (default: date) |
order |
?order=desc |
Sort order: asc or desc (default: desc) |
Examples
/noticias/
/noticias/?site=cabranoticias.com
/noticias/?after=2025-12-01T00:00:00&per_page=30
/noticias/?search=política&max_pages=2
/noticias/?site=source2.com&order=asc
Admin Panel
The API Noticias admin page provides:
- Sources Table: View all configured sources with edit/delete options
- Add/Edit Forms: Create or modify news sources with inline validation
- Status Messages: Confirmation feedback when sources are saved or deleted
Rewrite Rules
The plugin registers a custom rewrite rule for /noticias/. If the page doesn't load after activation:
- Go to Settings → Permalinks in WordPress admin
- Click Save Changes to flush rewrite rules
Alternatively, uncomment these lines in the plugin file:
register_activation_hook(__FILE__, function(){ flush_rewrite_rules(); });
register_deactivation_hook(__FILE__, function(){ flush_rewrite_rules(); });
Technical Details
- No Database Queries: News data is fetched via
wp_remote_get()on each request (consider caching for production) - Security: All user input is sanitized; external URLs are validated; output is properly escaped
- Pagination: Handles multi-page API responses automatically (respects
max_pageslimit) - Sorting: Client-side sort by publication date after merging all sources
- Featured Images: Requires
_embed=1parameter andwp:featuredmediain API response
Performance & Caching
For production environments with many sources or frequent visits, consider:
- Installing a caching plugin (WP Super Cache, W3 Total Cache) to cache
/noticias/responses - Setting reasonable
max_pageslimits in default parameters - Using shorter
per_pagevalues for faster API responses
Troubleshooting
| Issue | Solution |
|---|---|
/noticias/ returns 404 |
Flush rewrite rules: go to Settings → Permalinks → Save Changes |
| No featured images appear | Enable Use _embed for the source and verify API includes wp:featuredmedia |
| Posts not appearing | Verify the API endpoint is correct and accessible; check status parameter matches post status |
| Slow performance | Reduce max_pages or per_page; enable WordPress caching |
Requirements
- WordPress 5.0+
- PHP 7.2+
- External WordPress REST APIs accessible via
wp_remote_get()
License
License information to be added.
Author
Eduardo Valenzuela
Changelog
0.1.0
- Initial release
- Multi-source news rendering
- URL-based filtering and pagination
- Admin panel for source management