Ready to watch this entire course?
Become a member and get unlimited access to the entire skills library of over 4,974 courses, including more Design and personalized recommendations.Start Your Free Trial Now
- View Offline
- Exploring online portfolios
- Creating the site architecture
- Incorporating advanced custom post type functionalities
- Hooking a custom taxonomy to a post type
- Understanding how hierarchy relates to taxonomies
- Populating content into custom post types
- Handling multiple post type templates
- Displaying a list of links to the latest custom post type posts
- Building static pages for the front and the blog
- Creating a contact page with a contact form
Skill Level Advanced
So far in the course we've created three new custom post types with associated custom taxonomies. Now it's time to populate these post types and taxonomies with some actual real content so that we have something to work with once we start working on the front end of the site. In this movie, I will show you how to populate some photos and recipes and I will also show you how to import content that's been pre-built by us, if you have access to the full set of exercise files. If you don't have access to the exercise files, it doesn't really matter all that much.
All you really need here is some text content and some images that we can put in, so we have something to work with. So let's start off with the recipe. I will go to Recipes and click Add new recipe and then I will go to my assets, because I already have some recipes pre-built here. So I go under Assets > text and here we have a bunch of different text. I will pick one of them, artichoke_recipe, and I will copy the title, paste it into the title, and then I will copy the rest of the text.
Because I copied this out of Microsoft Word, I need to paste it in in a way that it doesn't bring with it all this extra styling content from Microsoft Word. And there's a tool for that inside WordPress. If you look at your toolbar here, you should see either one line of buttons or two lines of buttons. If you only see one, you can click on this button at the end here that says Show/Hide Kitchen Sink and then it will hide or show the bottom buttons. You need these second row buttons here to do this. On here, you have this button called Paste as Plain Text and if you click it, it opens a new window in which you can paste in your plain text, and then click Insert and it will be inserted without any style content.
Now we need to do some very quick editing of this text, just take out the extra spaces. I will change the ingredients to H2, so Heading 2, I will change each of the ingredients to a list item. So I'll just use a regular bullet list and then again some more plain text editing. I will change that to H2 too and then I will change each of the steps to an actual numbered list. Then I have to take out the numbers. And this kind of stuff seems tedious and unnecessary, but the reality is when you do it, you end up with a far more readable text.
If you think ahead about what you're doing and you actually make things more readable, for instance by creating real numbered lists, rather than just writing out the numbers, it will become easier for people to read it later. It will also become easier for search engines to understand what you're trying to do. So here you see we have a sub-item. So if I click on these Indent button, we'll get a sub-tem. It says A. The basic text editing tool in WordPress really provides you with all the same kind of text editing tools that you would expect from a full text editor; the only difference is it will happen inside WordPress itself.
So now we have a complete text, the next thing we need to do is fill out all these taxonomies. So we will start with Meal type. Steamed Artichoke sounds to me like an appetizer. I will click on Add new meal type and add Appetizer and click Add new meal type. So now we have the Appetizer meal type. Level of difficulty? This seems pretty easy to me, so I will say Easy and add that as a difficulty level.
Under Ingredients, we'll simply type out all the ingredients. Artichokes, garlic (cloves). And you see how I add commas after each of them. That means they're stacked as individual ingredients. You can also click Add for each individual one, but it takes more time. The comma approach is much easier. Once I have added all the ingredients, I can go to Preparation time and I am guessing this is going to take about 15 minutes and it will probably serve about 4 people.
Finally, I want to add an image, so I will go to the very beginning of the post and click the Add an Image button and then upload an image from my assets. So I will go to Exercise Files > Assets and photos and here I find some images of artichokes. So I will pick one that looks about right, upload it, and then I will give the image the same title and same alternate text as the title of the post itself or the title of the recipe and it's always very important to add the alternate text.
Even though it doesn't have a star next to it, it should have a star next to it. Now that the image is uploaded and has both the title and an alternate text, I am going to float it to the right, put it in as the medium size, and click Insert into Post. So now you see the image appears along with the rest of the text and I am ready to publish. So I will click Publish and then we can go and click View recipe. We can see now we have our complete post with an image.
I am going to do one last thing. I am going to put a little split in here. So at the end of the first paragraph, I will use this button here that's called Insert More Tag. All this does is it will add lines, so that if you are on an index page you only see what's above the line and not all the text. It just makes it easier to read the index pages. We'll update it again and we're done. The next step is to create a photo. The idea with the photos post type is to create a place where you only showcase photos of different items and you can also show multiple different photos of the same type of item.
So I will create a new photo here and I will call it artichokes and then I'll just add some photos. I will add this photo, just a big bowl of artichokes, and I will just call it that artichokes, set the Alternate Text as the same thing, and I will set this to Full Size, Center, and Insert into Post. Then I will add the Insert More Tag so that it breaks and underneath. I want to add a third image, only this time I will add it from my existing library because I already uploaded this photo to another post.
So instead of going and uploading it again, I am going to go to my Media Library here and here I'll see a list of all the images that are in the system and here we have that Steamed Artichokes with Creamy Garlic Aioli Sauce image. So I will click on Show and then Center, Full Size, Insert into Post. Now I see that the last image landed in the wrong place. So rather than doing a cut and paste from inside the Design view here, I am going to go to my HTML view, and cut and paste it from here. That way I know that I carry with me all the information I need.
So I'll go and look at the code and I should copy it from the beginning A tag till the end A tag. So if I simply cut that out and paste it into bottom. Go back to Visual. You'lll see we now have the right image at the top and then the two other images at the bottom. Finally, I need to add it as Meal type, and since this is the appetizer, I can check it as an Appetizer too, and then the Ingredient is Artichoke. Now, because we've already added artichokes as a tag or as an ingredient, when I start typing it, WordPress will suggest matching types, because you don't want to add tons of different versions of the same word.
So instead of adding a new one, I am going to pick the old one and click Add. And then finally, we're talking about photographic techniques, so I will call this one Lightbox and add the technique. Now, I can publish this post and again I can click View photo, and here you will see we have all the three photos of the artichoke displayed under the photo post type. So far we've created one recipe and one photo, but you need a lot more information. Therefore, I have compiled content for your site.
So if you have access to your exercise files, instead of doing all this work, you can just import existing content instead. So if you collapsed everything and you go down on the menu bar, you will see it says Tools. If you open Tools, there is a function called Import. Click on Import and you get to the Import screen, and here we have a list of different platforms from which we can import content. Now, we want to import from WordPress, so I will select WordPress, but because we've never done this before, I have to install the WordPress Content Importer.
It automatically opens the plugin installation window and I simply install it. And now WordPress will let me import. So I will click Activate Plugin & Run Importer and now I can start importing content. However, because my import file also contains some images, we're going to move the images into our site before we do the import so that they're already there. So I'll go down to my Assets again, click in Assets, and you will see there's a folder called uploads and if you go into your WordPress installation and you go into wp-content, you'll see there's a matching folder called uploads here too.
So what I am going to do is merge these two folders. I will simply drag it over from my Assets and copy it in and when we open it now you will see that we have a new folder with lots of extra images. These images will be called by the file we're going to import, which you can see here it's called culinaryartistryContent. So now we can go back to WordPress, choose the file culinaryartistryContent, and click Upload file and import.
We need to assign an author to it, so I'll just assign myself, and you have to also check this Download and import file attachments so that WordPress knows to look for those images we just dumped into the folder. When you click Submit, WordPress will run through all the contents and import all the content and put it into right places. When it's done, it will simply give you a message like this All done. Have fun! And if you're now going to post recipes or photos, you will see we have more content than we did before, and we can go and view any of these items and if everything worked, you should see not only the text but also images.
Populating a custom post type is no different from creating a regular post or page. All you do is fill out the information in the Admin Panel and your custom post is created for the world to see.