Chủ Nhật, 21 tháng 2, 2016

How to import wordpress test data

When building a custom theme, it's important to test it against all the different types of content people can place on that WordPress site the theme we're running on. Now, depending on the type of site you're building, you will need to build custom content that mimics what will actually go on the site. But regardless of what you are building, you need to test for all the basics, such as content types, HTML tags, image alignments, and so on. Now, building all that test content can take a really long time, but fortunately you don't actually have to do it. You can simply download what's known as the Theme Unit Test data for WordPress.

This is a full set of content for a WordPress site that covers all the bases and provides all the weird scenarios you need to test for. The Theme Unit Test data can be found at the Codex. Here you see you have page that explains how to install it, and I'll walk you through the process. The first step is to download the actual Theme Unit Test data. It's found in an XML file that you can download straight from here.

So I'll just right-click on it, save link as, and just save it under my Downloads folder. Then, can go to your WordPress site, go to the back-end, go to "Tools," and "Import," and from here, select "WordPress." If you haven't used the WordPress Importer before, you'll have to install it.

It's an external plugin you can install inside WordPress and you go to that plugin installer automatically when you click on WordPress. So from here I'll click "Install Now." The plugin is downloaded, unpacked and installed, and now I can activate the plugin and run the importer at the same time. So I'll click on that, and you'll notice this will produce the same action as if I went to "Tools," "Import," and "WordPress." From here, I can now choose the file I just downloaded. So I'll select "Choose File," go to "Downloads," find "theme-unit-test-data," and click "Open," and then click "Upload file and import." Now the file is uploaded into my WordPress installation and WordPress has some more questions for me.
First, it wants to know if I want to import the existing authors that are contained within this imported file. So here you see we have one, two, three and four authors. You can choose to just import them the way they are, or you can create a new user and login name for each of these authors, or you can assign each of the author content to a specific user. But I'm just going to leave it the way it is. Next, and importantly, you get the Import Attachments option. You need to check this box to download and import the file attachments, otherwise you will have a bunch of empty boxes where images should be but aren't.

So if you check this box, WordPress will go out on the web, grab all this content, and pull it into your site so you get all the images and other media elements. Once you've checked this box, click on "Submit." Now WordPress will run through the entire XML file and import all the content including pulling down content from the web. This will take a little while, and while the process is running you'll just see this white screen. The only thing you have to remember here is don't click the back button, because if you click the back button you stop the process.So just let this process run.
And when it's done, you get this message. "Import WordPress "All done. Have fun!" So check out what happened now. If I go to the front-end of my site again, I now have a ton of content. You can see here at the top I have a gigantic menu with lots of dropdowns, here I have a bunch of posts with lots of different types of content in it, and if I go to the back-end and go to "Posts," you'll see we have a long list of actual posts. We have a scheduled post, a draft post, a markup post that shows all the different HTML tags and formatting you can add to a post.

We have an image alignment post, a text alignment post, a title with special characters post, and so on and so on. And this is the point of the Theme Unit Test data. It provides you with all the types of posts and pages you can create, and within those posts and pages you will haveall the different types of content you can create. So, we have a post that shows all the different types of image alignment you can do. Here we have a center aligned image, a left aligned image, a very large image, a right aligned image, a center aligned image with a caption, and so on.
You also have other types of posts like a password protected post, and a comments disabled post, and a template with comments. This one in particular, if you go and view it, you'll see it has 19 comments. In these comments, you again have all the different types of HTML the users can insert into your comments. So using the Theme Unit Test data in your site allows you to see what types of content may end up on the site, and ensure that you are styling and formatting everything properly. As we progress through the course, I encourage you to go check out all the different types of content you've downloaded with the Theme Unit Test data, find out what each of the posts and pages and menus contain and make sure you understand it so that as we progress through the course you'll be able to compare what you're doing to actual content and make sure that every piece of content works the way it's intended to.

Không có nhận xét nào:

Đăng nhận xét