Skip to content
Masaguz.com
Masaguz.com

Personal Blog

  • Home
  • Tutorial
    • VPS Linux
  • Personal
Masaguz.com

Personal Blog

WP-CLI Import Content

masaguz, November 8, 2023November 18, 2023

Rather than using the WordPress admin to import a WXR file, you might find it helpful to use WP-CLI instead.

By importing with WP-CLI instead of the WordPress admin, you’ll also have additional options available to you, such as skipping certain types of data.

Importing WordPress WXR (.xml) Files

To perform a simple import of your file, just use the following command:

wp import my-file.xml
Shell

Modifying Author Behavior

When importing a WXR file, you might have a situation where the post author in the export file doesn’t exist on the site that it’s being imported into. In that case, you can use the –authors option to define how to proceed with the import.

Creating Non-Existent Authors

If you want to create any authors that don’t already exist, set value of the –authors option to create like this:

wp import my-file.xml --authors=create
Shell

Skipping Non-Existent Authors

If you’d like to just leave the post’s author empty if the user doesn’t already exist, you can set the value of the –authors option to skip:

wp import my-file.xml --authors=skip
Shell

Custom Mapping Authors

What if you want to associate your authors from the exported site with different users on the new site? WP-CLI allows for a custom CSV file to be provided. The CSV should be formatted as 2 columns with old_user_login and new_user_login as column headers like this:

old_user_login new_user_login
user1 newuser1
anotheruser somethingelse

To use the custom user mapping that you’ve defined within the CSV, just define the path within the –authors option like this:

wp import my-file.xml --authors=my_file.csv
Shell

Skipping Content Types

When performing an import of your WXR file, you also have the option to skip certain types of data, such as attachments or thumbnail generation.

Skipping Attachment Imports

If you don’t want to import any of the attachments that are listed inside the WXR file, you can use the –skip option with the attachment data type like this:

wp import my-file.xml --skip=attachment
Shell

Skipping Thumbnail Generation

What is you still want to import your post attachments but don’t want to generate new thumbnails when the import occurs? Just use the –skip option with image_resize as the value like this:

wp import my-file.csv --skip=image_resize
VPS Linux

Post navigation

Previous post

Related Posts

VPS Linux

VPS , Agar wordpress nggak selalu minta akses ftp waktu update themes atau plugins

November 3, 2023November 18, 2023

chown -R www-data:www-data /var/www/

Read More
VPS Linux

Nambah Virtual Host Apache

November 4, 2023November 18, 2023

Create a new directory in /var/www/ for your domain. Just replace mydomain.com with your own….

Read More
VPS Linux

Apache sub post/page not found

November 7, 2023November 18, 2023

In gara-gara setting di apache2.conf, sudo nano /etc/apache2/apache2.conf Ganti : <Directory /var/www/> Options Indexes FollowSymLinks…

Read More

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • WP-CLI Import Content
  • Apache sub post/page not found
  • Apache error “Could not reliably determine the server’s fully qualified domain name”
  • Setting Apache, Mysql, PHP
  • Nambah Virtual Host Apache

Recent Comments

No comments to show.

Archives

  • November 2023

Categories

  • Pengalaman Pribadi
  • VPS Linux
©2023 Masaguz.com