
Table of Contents
Planning to transfer content to your WordPress site? Wondering if it’s possible without a plugin? The good news is: yes, you can! In this guide, we’ll show you how to import your content into WordPress without relying on third-party plugins, using only the powerful built-in features of WordPress.
Fortunately, WordPress offers several built-in options that allow you to import without relying on a third-party plugin. It also supports various file types that cater to your specific needs.
In this tutorial, we will guide you through the step-by-step process of importing programmatically to WordPress without the use of a third-party plugin.
Warning 1: Backup before you proceed
Always back up your website and data before performing any major updates or imports, even if you’re not using a plugin. It ensures you can easily revert your site to its previous state if anything goes wrong.
Warning 2: Potential risks involved
Be aware that importing content without a plugin may cause compatibility issues with themes or plugins, potentially breaking your website’s design or functionality. It also increases the risk of security vulnerabilities if the content with malicious code or scripts gets injected while importing.
How to Use Built-in WordPress Functions for Importing
Looking to import multiple posts into your WordPress site without manually adding them one by one? Here’s a solution for you!
You can import posts as CSV using the built-in WordPress function wp_insert_post(). This function allows you to programmatically create and insert them into the database.
Here’s how you can use this function:
First, make sure your file is uploaded to your server or host through ssh, cpanel, ftp, or sftp, for example in the directory /var/www/html/wp-content/uploads/posts.csv.
Next, add the following code snippet to your theme’s functions.php file e.g: wp-contentthemestwentytwentythreefunctions.php
if (($handle = fopen("/var/www/html/feb/wordpress/wp-
content/uploads/smack_uci_uploads/imports/d107020a28796c63d6984ad91f0fcab5/post.csv", "r")) !== FALSE) {
// Read the CSV file line by line
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
// Create a new post object and set its properties
$post = array(
'post_title' => $data[0],
'post_content' => $data[1],
'post_status' => 'publish',
'post_type' => 'post',
);
// Insert the post into the database
$post_id = wp_insert_post($post);
// Check if the post was inserted successfully
if ($post_id > 0) {
// Post was inserted successfully, do something else if needed
} else {
// Post was not inserted, handle the error if needed
}
}
fclose($handle);
}
Don’t forget to save your changes to the functions.php file.
You can also edit the theme file from Appearance > Theme File Editor

Running the page URL in your browser will trigger the import process automatically. You can view it from the WP-Admin panel to check if all the records were inserted successfully.That’s it! You’re done now. Keep in mind that this is just a basic example, and you can modify the code to suit your specific needs. For example, you can add additional code to handle custom post types, taxonomies, or other properties. Also, you can customize to use the code snippet in any filter or action hook based on your trigger function. If you need more help or would like to see additional use cases, additional examples, and code snippets, do not hesitate to reach out to us! You can leave a comment below or use the contact form, and we’ll be happy to update the tutorial with more information to help you out.
How to use the wp-cli method
Another method for importing users from CSV without a plugin is using WP-CLI. This method is pretty straightforward to follow. First, you need to prepare a file in a specific format, which should look something like this:
user_login,user_email,display_name,role,authors_parameter
Johndoe,[email protected],John Doe,contributor,create
smacksupport,[email protected],smackcoders,administrator,create
jiju2fabio,[email protected],jiju2fabio,author,create
You can create or update your user CSV file to match this structure. If you want to use the same sample that we’ve used in this tutorial, you can download it for training purposes. Once you have your file ready, upload it to your uploads folder, and the path to the file should be /var/www/html/wp-content/uploads/users.csv.
Once WP-CLI is installed, you can use this command to import your CSV file:
wp user import-csv /var/www/html/wp-content/uploads/users.csv
And that’s it! Your users should be imported now. You can also upload the file from a remote URL using this method.
However, It’s important to note that this method is only useful for importing users as a CSV. If you’re looking to import posts from a CSV, the WP function method is the better option. The wp-cli method is only compatible with WXR files, which can be complicated. So, if you want to import posts, it’s best to stick with the first method we discussed.

WP Ultimate CSV Importer Pro
Get Ultimate CSV/XML Importer to import data on WordPress faster, quicker and safer.
Access WordPress’s built-in import tools by going to your WP-Admin dashboard, clicking on ‘Tools,’ and selecting ‘Import.’ From there, you’ll see a table with different options available. Depending on your needs, you can choose the option that suits you best. For example, if you want to migrate from a Blogger blog, you can use the Blogger option. If you want to import from an RSS feed, you can use the RSS option. If you want to transfer from an export file in WXR format, which supports posts, pages, comments, custom fields, categories, and tags, you can choose the WordPress run importer option.
However, keep in mind that these default tools have limitations. You can only use them for a one-time process, and you cannot automate or schedule the process. Also, filters and partial imports may not work correctly, and there is no proper support or fixes available.
Don’t worry; if you need more robust and reliable tools, third-party plugins like WP Ultimate CSV Importer available that can help you out. Here are some plugins you can try
- https://wordpress.org/plugins/one-click-demo-import/
- https://wordpress.org/plugins/advanced-import/
- https://wordpress.org/plugins/import-facebook-events
Import users from a CSV into WordPress without a plugin
Follow the below basic steps to import users from a CSV file into WordPress without using a plugin. This involves writing custom code using PHP and WordPress functions. Please note that this example assumes a basic CSV structure with headers like username, email, and password.
Prepare Your CSV File
First, create a CSV file with user data, including headers (e.g.username, email, password).
Save the CSV file in a location accessible by your WordPress installation.
Create a Custom PHP Script
Once you create a CSV file, then create a custom PHP script in your WordPress theme or the root of your WordPress installation (e.g.,import-users.php).
Write PHP code for import
Open your custom PHP script and use the following code to import users from the CSV file.
<?php
// Include WordPress functions
define(‘WP_USE_THEMES’, false);
require(‘path/to/wp-load.php’);
// Path to your CSV file
$csvFilePath = ‘path/to/your/users.csv’;
// Function to create a new user
function create_user($username, $email, $password) {
$user_id = wp_create_user($username, $password, $email);
if (is_wp_error($user_id)) {
echo ‘Error creating user ‘. $username . ‘: ‘ . $user_id->get_error_message() . ‘<br>’;
} else {
echo ‘User ‘ . $username . ‘ created successfully.<br>’;
}
}
// Read CSV file
if (($handle = fopen($csvFilePath, ‘r’)) !== false) {
while (($data = fgetcsv($handle, 1000, ‘,’)) !== false) {
$username = $data[0];
$email = $data[1];
$password = $data[2];
// Check if the user already exists
$user_exists = username_exists($username);
if (!$user_exists) {
create_user($username, $email, $password);
} else {
echo ‘User ‘ . $username . ‘ already exists.<br>’;
}
}
fclose($handle);
} else {
echo ‘Error opening CSV file.<br>’;
}
Run your Script
Then access your script via a web browser (e.g., http://yourdomain.com/import-users.php).
This will execute the script, importing users from the CSV file.
How to plan a simple migration
Before you begin importing data, it’s essential to have a clear plan in place. Let’s discuss some takeaways that can help you choose the right option.
Firstly, if you want to import user metadata as CSV, you can do it programmatically using wp-cli without the need for any plugin. Secondly, you can use the WP function method by customizing the shared code to your specific needs. If you have WooCommerce installed and active, you can import products and tax details as CSV without needing another plugin.
If you’re planning to use WXR for your import, WP-CLI is an option, though it requires more time and effort. The simplest approach is to use the default WordPress importer.
Moreover, there are other options available for bloggers, Tumblr, LiveJournal, Movable Type, TypePad, etc., and from an RSS feed as well. Understanding the strengths and limitations of each option will help you choose the best method for your import needs.
Also, It’s important to know about each file type supported by WordPress. Let me explain each file type in detail so that you can understand it better.
- WXR stands for WordPress eXtended RSS. It is an XML-based file format that contains content, categories, and tags. It is the most common file format used for importing and exporting data.
- XML: It stands for eXtensible Markup Language. It is a file format that is used to store and transport data. WordPress uses XML to export and import content.
- CSV: It stands for Comma Separated Values. It is a file format that stores data in a tabular form where each column is separated by a comma. CSV files are commonly used to store data like product information, user data, and more.
- RSS: It stands for Really Simple Syndication. It is a file format used to publish frequently updated content. It also allows you to import RSS feeds into your site. JSON: It stands for JavaScript Object Notation. It is a file format used to store and exchange data.
So, those are the file types supported. It’s important to choose the right file format based on your data and requirements.
We hope this guide helps you successfully import your content into WordPress. Some useful References: If you want to learn more about the WP-CLI method, you can visit the WP-CLI website. For using the WP function method, you can use the wp_insert_post() function. This function allows you to programmatically insert data into your WordPress site. You can learn more about it from the WP developer reference.
Why the CSV Importer plugin is better for Quality content Import?
Importing CSV files into a website or application is a common task, especially in content management systems like WordPress. Though it’s possible to import CSV files manually or without a plugin, using a dedicated CSV importer plugin offers several advantages and can be crucial for efficiency, accuracy, and data integrity.
While it’s technically possible to import CSV files manually or without a plugin, using a dedicated CSV importer plugin offers numerous benefits in terms of efficiency, accuracy, data integrity, and user experience. Whether you’re importing product listings, user data, content, or any other type of information, leveraging a CSV importer plugin can streamline the process and mitigate potential risks associated with manual import methods.

WP Ultimate CSV Importer Pro
Get Ultimate CSV/XML Importer to import data on WordPress faster, quicker and safer.
Conclusion
Lastly, if you want to use the WordPress default options, you can find them in the plugin repository. Importing your content into WordPress can be streamlined with the right tools and an understanding of your options, and knowing the limitations and capabilities of each option. While you can import CSV files into WordPress without a plugin, it requires more manual effort and time. Using the Ultimate CSV Importer plugin is an easy and efficient way to import content with just a few clicks.
With these tips, you can transfer your content smoothly and focus on creating valuable content for your audience.