Presentation of the order
The order sonata-extra:wordpress-importer is designed to import images, categories, posts, and tags from a WordPress site into your application. It facilitates the transfer of WordPress content into the application.
Syntax
sonata-extra:wordpress-importer --url=[WORDPRESS_SITE_URL] --user=[USERNAME] --token="[TOKEN]"
Settings
--url: The URL of the WordPress site from which the content must be imported.--user: Your WordPress username.--token: The authentication token for API access.
Generating a WordPress login token using the REST API
To use the command sonata-extra:wordpress-importer, a valid authentication token for the WordPress REST API is required. Here is the procedure to generate this token.
Step 1: Log in to the WordPress admin panel
Access the WordPress admin panel by navigating to https://www.website.com/wp-admin.
Step 2: Activate the REST API
Make sure that the WordPress REST API is enabled, which is the default setting in the latest versions of WordPress.
Step 3: Create an app password
- Open
Utilisateurs>Profil. - Spot the section
Mots de passe d’application. - Enter the application password, then click on the add button.
- Note the generated password, as it will be used as your token.
Step 4: Use the app password
The generated application password will serve as a token for the command sonata-extra:wordpress-importer.
Step 5: Run the command with the token
Use the generated application password as a token in your command:
symfony console sonata-extra:wordpress-importer --url=[WORDPRESS_SITE_URL] --user=[USERNAME] --token="[APPLICATION_PASSWORD]"
Replace [WORDPRESS_SITE_URL], [USERNAME] and [APPLICATION_PASSWORD] with the actual URL of your WordPress site, your username, and the application password that you generated.
Preview before importing

First work on a copy of the database. Inventory the types of content, taxonomies, authors, and media, then compare the volumes before/after. The import should only be restarted in production after verifying its idempotence.