| Install | |
|---|---|
composer require inspiredminds/contao-wordpressimport |
|
| Latest Version: | 2.2.1 |
| PHP: | >=7.1 |
Contao 4 extension that allows you to import news articles from WordPress posts via the WordPress JSON API.
Require the bundle via composer:
composer require inspiredminds/contao-wordpressimport
If you use the Contao Standard Edition, you will have to add
new WordPressImportBundle\WordPressImportBundle()
to your AppKernel.php.
Then execute the Contao Install Tool to update the database.
Once installed, you will have new options within a news archive:

news_categories extension installed.To import the WordPress posts into your Contao installation, you can use the following console command:
vendor/bin/contao-console wordpressimport
Optionally you can define the limit of how many WordPress posts are imported in one go:
vendor/bin/contao-console wordpressimport 10
This will only import 10 WordPress posts at a time.
Use bin/console in the Contao Standard Edition.
If you activated the periodic import, the WordPress posts will be imported hourly by Contao's cronjob.
Note: by default only 10 items will be imported with each cronjob execution. The import can take a long time (depending on the number of WordPress posts and the number of images to be downloaded). This limit is there so that a cronjob execution does not block a user's request for a long time (or at least until the max_execution_time limit is hit) in case you are relying on the web cron. You can change this limit in the System Settings.
Version 2.1.0 introduced an WordPressImportBundle\Event\ImportWordPressPostEvent which is fired for each imported WordPress post after it has been fully processed by the extension. It holds references to the used HTTP client instance, the WordPress post object and the Contao\NewsModel instance. This allows you to modify the imported news article.
Since version 2.2.0 there is also an WordPressImportBundle\Event\ApiResponseBodyEvent which is fired for each
response of WordPress' REST API. This will let you fix invalid JSON output for example, before processing the response
further (see here).