Wordpress Plugin - Json Articles
Back when I was attempting to be a small hosting business in Western Mass, I ran a side site for supporting my clients where I wrote most of the articles you now see here. In addition to displaying them on my support site, I also wanted to be able to display them on the companies main site.
Rather than rewriting, or exporting/importing the articles, I decided to leverage the built-in WordPress Rest API and wrote this plugin to do it all for me.
What this plugin does is pulls in articles from another WordPress site through the normal json endpoints, it then parses the categories, tags, and attempts to pull the media. You can change the permalinks for each, create a sidebar and add widgets to existing sidebars.
We do inject an “Original Article” with the link back to the original page. You cannot remove this link through the plugin, please do not hack it to remove and give credit where credit is due!
- Ability to pull blog articles from another WordPress website
- Configured site must have the JSON API enabled.
- Creates or Updates posts, categories, tags, and tries to create the media for the posts
- Configurable and filterable by category, tag, or date range of articles to pull.
- Configurable permalinks
- Number of articles to pull (max 100, this is a WordPress JSON API limit)
- Manual, cron, and cli based syncing.
- I would not recommend manual syncing for anything over 20 articles
- Includes basic templates
- To use them, simply copy the files in this plugins
templates/directory to your theme’s root directory and make your modifications.
- To use them, simply copy the files in this plugins
Directions & Settings
- Download the plugin, unzip it, and upload to your sites
- You can also upload it directly to your Plugins admin
- Activate the plugin through the ‘Plugins’ menu in WordPress
Settings & Sync
- Site URLThe full URL to the site you wish to attempt to pull articles from, ex… http(s)://yoursite.comNOTES: The site you are pulling from must allow the JSON API, and you do not need to know the endpoints for the posts, the plugin takes care of that for you.
- Article PermalinkThe base permalink for displaying the articles.
- Category PermalinkThe base permalink for displaying the article categories.
- Tag PermalinkThe base permalink for displaying the article tags.
- Article Display CountHow many articles should be displayed per page?
- Article Pull CountHow many articles should the sync pull?NOTE: WordPress JSON only allows a maximum of 100 articles.
- Category Filter Comma-delimited list of categories from the originating site to pull the articles from.NOTE: Defaults to all Categories
- Tag Filter Comma-delimited list of tags from the originating site to pull the articles from.NOTE: Defaults to all Tags
- Date Filter – Start “Published On” start date pull the articles from the originating site.NOTE: Defaults to all
- Date Filter – End “Published On” end date pull the articles from the originating site.NOTE: Defaults to all
- Sync Span Select the span of time that you would like to sync the articles. Pulls the pre-exising WordPress scheduling.
- Manual Sync Click to manually sync the articles, please stay on the page while it is running to prevent any interuptions.NOTE: I do not recommend doing this for any pull over 10 or so articles. It could timeout.
- CLI Sync Log into your webservers shell, and run the following command in your sites root:
wp kp_ja sync.NOTE: If your site is a multisite install, specifically a subdomain type, please add this flag to your command:
Sidebar & Widgets
- Sidebar – JSON Articles We added a sidebar for use in the article templates if you need to.
- JSON Article Categories Works exactly like the built-in “Categories” widget, except pulls from these JSON Articles.
- JSON Article Tags Displays a tag cloud of the JSON Articles Tags.
- JSON Recent Articles Displays a menu of the most recent JSON Articles.
Articles and Templates
- Files – main location:
wp-content/THISPLUGIN/templates/*To override our template simply copy them to your themes root directory, and make your modifications.
kpja-archives.phpThis is the main article listing page, just like your
kpja-category.phpThis is the article category listing page, just like your
kpja-single.phpThis is the single article page, just like your
kpja-tag.phpThis is the article tag listing page, just like your
= 0.8.77 = * VERIFY: Core 5.9 Compliant * FEATURE: create some action hooks, listed below * `kpja_admin_permissions` - fires off after the admin pages permissions are squared away for the articles. done in case developers need more control over the permissions already set * `kpja_pre_cpt_create` - fires off before the custom post type is created * `kpja_post_cpt_create` - fires off after the custom post type is created * `kpja_pre_tax_create` - fires off before the taxonomies are created * `kpja_post_tax_create` - fires off after the taxonomies are created * FIX: Revamped the article image pulling. Should get all post thumbnails attached to a remote post now. - implemented a sample in the template kpja-single.php to show it working. = 0.7.14 = * VERIFY: Core 5.8.1 Compliant = 0.7.13 = * FIX: remote pull issue on non-https * FIX: throw proper error messages on issue * FIX: proper OR for file DIE on direct access * FIX: properly pull the documentation and sync info pages * FIX/FEATURE: replace get with safe get * FEATURE: strongly type methods * FEATURE: updated comments to phpdoc format = 0.6.97 = * framework update * 5.8 compatibility * force php 7.3 minimum = 0.3.13 = * framework update * WP Core Version update = 0.2.07 = * Check for existing classes * Test for 5.7 compliance * Remove un-necessary includes * CLI sync performance * Update field framework = 0.1.91 = * First public release