Build Your Own Business Website header image

Case Study Part 3 – Convert Posts to Custom Post Types

Difficulty Level -

Whoops, you've found some premium content!

Watch the opening clip of this video to preview it,
the full video is available to paid members.

This is the third in a series of live lessons on using WordPress and Thesis as a Content Management System (CMS).  In this case study we are creating a community news site.  We will now create 2 new custom post types, 1 for each community using the Custom Post Type UI plugin.  Next we need to convert our sample test posts to our new custom post types.  We will be using the Post Type Switcher plugin.

Video Transcript

Let’s see… oops. Okay, Douglas. I came in a few minutes late and I think you may have addressed my question earlier today. I’m trying to place posts by category in a little static page, arranging these using custom taxonomy on blog pages to organize post. It’s not too complex for a call-in, Douglas. It is the presentation I prepared for the 2nd half of his evening is talking about how to accomplish that. Now I did do about half an hour on it this morning and those hopefully will be posted… those lessons hopefully would be posted tomorrow under Live Answers. You can listen to that one. Hopefully, you’ll be able to follow along with the second half of that here. There may even be a 3rd half of that depending upon how long this takes but we’ll just jump right into that right now.

And so to refresh everybody’s memory, what’s going on here is that Douglas wants to have a community website where you have a post for each individual community that way you can show essentially a blog page for each community. So, example, I’m using right now… we’re using Seattle and Edmonds. Each of those are communities, we have those 2 communities and we want to have a blog page for Seattle and a blog page for Edmonds. Now it’s not actually going to be a blog page, it’s just going to look like a blog page. And in this morning’s session, we created this website called “Community News Case Study” and on this website, we installed the plugin Custom Post Type UI. And one of the things I discovered was that in order for us to make the permalink structure work properly so that your permalink would read you know, you know, so you would have a consistently properly organized permalink… the only way to really accomplish that currently and maybe even until WordPress 3.2, is not to use the custom taxonomies but to instead use custom post types. So we install this plugin – Custom Post Type UI and we are going to create a custom post type for each community.

So we created the first custom post type called Edmonds and I am going to create a new custom post type and we are going to call that Seattle. This is in that plugin. The plugin is called Custom Post Types UI and we’re using that dialogue in order to create this. So label is Seattle and then we’re going to look at Advanced Options. It’s going to be public. We want the UI to show. It’s going to have the capability of post. It’s not going to be hierarchical. It’s definitely going to use a rewrite. We’re going to leave that as default. It’s going to be queriable from the homepage. We’re not going to bother with the menu position. It is going to support all of these things and it’s going to have categories and post tags as its built-in taxonomies. So now we create this custom post type.

And so now we have a custom post type for Edmonds News and a custom post type for Seattle. Actually, I should change that. I said Seattle but I should say Seattle News so I’m going to manage post types and then we’re going to edit post types. It’s going to be Seattle and then Seattle News and then Seattle News. And then we’re going to save the custom post type again. Now it says Seattle News, Add Seattle News, Edmonds News. If we click on this, this is exactly the same as if we’ve clicked on post. You can see if you’ve clicked on post, it’s going to Add New and it’s got Categories and it’s got Post Tags. This says Seattle News and then Add Seattle News and then Category and Post Tags and then Edmonds News, Add Edmonds News, Categories and Post Tags.

Now when we created this website, we imported all of this data which is a whole bunch of posts and we need to convert those posts into this custom post types. So we need to download another plugin. And because right now, all of these posts that I imported are actually posts and do not fall inside this custom post type. And so what we’re going to do is we’re going to add a new plugin. The plugin we’re going to add is called Post Type Switcher. It just gives us a real sort of easy way to switch the post type of any given element or any given type of post whether post page or custom post type. So we’re going to search for that Post Type Switcher and this is the one we’re going to download and install. Now you can see that it says it’s already installed because I practiced with this earlier. So we do have that Post Type Switcher installed and what I need to do now then is just activate because I deactivated it and that is Post Type Switcher and activate it. And now I need to add some posts to the Seattle News. So what I do is come over here and post and I’m going to come over here and let’s see, edit and then post types here. I’m just going to pick Seattle News. Let’s say okay, update then back to post and edit and Seattle News and update. And now you can see that if we’re in Seattle News, we have… whoops. I must have failed to… I did. I must have failed to save that. So we go to Seattle News, okay. Update.

Now if we go to Seattle News, it’s there. Now that’s… we’re switching post types because what we wanted is that data to be inserted into each of these 2 different groups or custom post types, both Seattle and Edmonds. And so right now, I have 2 in each. And these ones actually, don’t have a category anymore so I’m just going to edit them and add a category to them and the Northern Spy is a red apple. So we’ll update that one and then the Jonamack is also… no, Jonamack is a yellow apple. So click at it and we’ll go to yellow apple. I’m going to make sure it’s not uncategorized and hit update. Go back over here to click edit and make sure it’s not uncategorized, hit update. So now we have a couple of categories for red apples and yellow apples inside of Seattle News and then we have inside of Edmonds News, we have 2 posts categorized as cherries.

So that is the… what we should do really is go through all of these posts and assign them to various places but we’re going to start off simply by using those two.

0 Comments… add one

Save $200 on Membership Now!

Start learning today for as little as
$0.82 PER DAY!
Subscription Options
0 comments… add one

Leave a Comment