Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
As noted earlier in the course, WordPress stores all the site's post pages and other info safely in a database so you never have to worry, right? Because nothing ever goes wrong, right? Well, in the real world, things do happen, servers crash, data gets corrupted, web host go offline. It's best to be safe and know how to take control of your WordPress data. In this chapter we'll examine two ways to do just that. One method outside of WordPress and in this lesson one method built right in.
WordPress includes tools for both exporting and importing its data. You'll find them handily stored right under the Tools menu. So let's take a look at Export first. WordPress exports its data to a text file utilizing a version of XML they call WordPress eXtended RSS, or WXR. Honestly, it doesn't matter what they call it because it just works, and the only thing it's really useful for is outputting your data so you can import it using another of their tools which we'll get into a little bit later.
As you can see, from the Export screen you have the option of exporting All of your data or just the Posts or just the Pages. Let's try it out with the Export All Content option. So I'm going to click Download Export File. Google Chrome will save it down here to the bottom. I'm going to show it in Finder, and there is a file. WordPress automatically gives a file a name that includes your site name, the word WordPress, so you know where the data came from, and the date. This is really helpful when making backups on a regular basis.
Now let's switch over to Dreamweaver and open up that file, because as you probably know Dreamweaver speaks XML quite well. So I'll go to File > Open, navigate to my Downloads and then double-click on that XML file. Up top in the Comments section, there are some instructions on how to work with this file, primarily importing it back into WordPress, which we'll cover later in this lesson. Then after that, the actual data begins. Let's scroll down a little bit, and here we can see a number of categories being defined.
You see both the term_id listed as the first item and then after that what WordPress calls the category_nicename, and what's shown in the Dashboard as the slug. A little further down, you'll start to see some sample content. Now this is the page that's included as a sample page, and once we get past that, we can see some content that we entered. Chances are you won't really need to open the file and look at anything or manipulate anything. You just use it as a source file that you can later import. Besides backing up your data, one of the primary uses that I found with WordPress' Export Import features is to move content developed locally to a live site.
So to demonstrate that, I've set up another WordPress installation on my local server here called roux2 so you can see how it's done. Let's go back to the browser, and there's a second tab here shows my roux2 site, as you can see by the path up there, and I'll click Dismiss. I've also named the site Roux Academy Live just to distinguish it from our development site. As you can see, this WordPress site is brand-new, just-installed condition. So let's bring in the data that we exported, and we'll see what happens.
So I go to Tools and choose Import. You'll find a host of import possibilities. The one we're most interested in is the last one, WordPress. So click that. Now that, that's installed, let's Activate the Plug-in and Run the Importer. So we get to choose an exported file, which as you recall we put in our Downloads folder and here it is here. So I'll select that. Click Open and then Upload file and import. After WordPress has brought in the file it reads through all the users, and as it says, sets up new passwords that are randomly generated for each one.
Now you will need to go in and modify those passwords to make sure that they're properly set up. So you have the option for importing an author and putting them on a new username or assigning them to an existing user. In this case, we're going to set it up as admin and importing another author here which I could put in as a separate username if I wanted to. I don't really want to assign it to my only other existing user. So one strategy is you might before you import set up additional users and bring in that data, if you know ahead of time that you're working with that kind of situation.
The option for downloading and importing file attachments, and let's click that and then click Submit. It reminds you to update the passwords and roles of imported users. So you would want to go over and edit Debra's and then put in her New Password or her old password, Update the User. Now let's head over to the Dashboard to see that we have our post that we've added. Now it does because it's a new installation that we're bringing data in.
You're going to find all of that placeholder content still there. It won't remove data that's already there, such as the Hello world, or if we go to Pages, the Sample Pages, and because I didn't remove sample page before installation you'll see it twice. So it's one that came in with the original installation and one that was still in my data that I imported. So let's take a look at the site. Now don't be shocked. But when you first choose it you may very well be, because the first time I saw what was happening I thought, oh no, I've lost all of that work. Well, you haven't.
WordPress just uses the default theme. It brings in just the content, the posts, and the pages. It does not bring in your theme. So you've the option for zipping up your theme folders--both parent and child in our case-- and installing them or just transferring the files. I'm going to use Finder to copy custom and roux theme folders. So here are my two sites. I'm going to extend roux_academy and then go down into blog, and open up content, open up themes.
Here is custom and here's roux. I'm going to copy both of those and then close that down. Now this particular site that I have here doesn't use a separate blog folder or anything. So wp-content is going to be in the site root. I'll expand, and then just let me double- click on themes to dive into that exclusively and then I'll paste in my two folders. Let's head back to the Dashboard, and now I can go to Appearance > Themes, and you'll see my available themes listed here.
Let's Activate Roux and then head on over to our site one more time, and now our blog site is back in all of its glory. There is definitely some clean-up you'll need to do. Be sure to budget that time in. I checked all the various sections of WordPress, Posts, Pages, Categories, Tags, and removed any unwanted elements. While it's not the most robust solution, WordPress' Import and Export feature definitely fits the need. In the next lesson I'll show you an alternative approach.
Get unlimited access to all courses for just $25/month.Become a member