We have been building a community news site as a case study. On that site we are using a custom post type for each community. Thus the Edmonds community has the “Edmonds News” post type and the Seattle community has the “Seattle News” post type.
In this video we set up and configure a permalink structure that includes the custom post type name within the page’s URL. In this video we discuss:
- Setting permalinks
- Installing Custom Post Permalinks plugin
- Re-configuring permalinks using Custom Post Permalinks
- Demonstrate how this works with categories
A note about Permalink structure in WordPress 3.3. It is no longer necessary to include a number in your permalink structure if you are starting a new website with WordPress 3.3.
Rick: So and now if we go down to our permalink… well, before we go to our permalinks, if you’d just go to Edmonds News and we view this, you can see that the permalink structure is ?Edmonds=rainiersweetcherry2 which is actually not a particularly good permalink. So what we’re going to do is we’re going to come down to Settings and permalinks. And we are going to use my general mechanism for doing this which is I usually start with month and name and then I come down and select Custom Structure and I cut out month num, replace year with month num and in place of month num, I put category. Save those changes and this is my standard custom URL structure. This give you a good SEO URL and it also keeps the searching for posts sufficient for WordPress by having it start off with a number.
And so now if we come back over to our Edmonds News and we view that, now you can see that it is byobtutorial or mycommunitynewssite/Edmonds/rainiersweetcherry2. Now you’ll notice that even though this sweet cherry 2 is a cherry post (Wasn’t that funny?), it’s not showing up. I need to refresh my permalinks, I guess. Permalinks, save changes, refresh. There we go. Sometimes when the permalinks aren’t working, you need to just go back and refresh them, save them. It flushes the old permalink rules and resets them.
So you’ll notice the categories are missing now. What would be ideal here is Edmonds/cherries/rainiersweetcherry2 or Edmonds/weekendevents/thisweekendsevent right? So that’s what you’d really like to see here. So in order for us to do that, we need to use a different plugin and that is the plugin called Custom Post Permalinks because right now, WordPress does not have sufficient support for permalink structure with custom post types and custom taxonomies. We are going to use a plugin that helps us with that.
So Custom Post Permalinks, if we come back over here and say, plugins add new… custom post permalinks, search for the plugin, Okay, you can see it’s already installed but there it is. So we go down to that plugin and we activate that.
And so now with that activated, I have a whole bunch of more control over that URL. So we come back down and to find that control, we have to go to permalink. And now you can see it’s got this whole new setting down here for us to reconfigure our permalinks. And in fact, it’s remembering what I did last time when I had this set up earlier today.
Here’s where it starts off. It starts off with the /Seattle as the beginning and then this Seattle, actually means the same thing as post name. Post name is only going to stand for post and pages but Seattle here means the Seattle post name. And so if we save this just like this, the net result for Seattle is going to no different than it was before. So if we hit Save Changes and we come back over…let’s see. If we go back to the dashboard and go to Seattle news and then view that, you can see that it says Seattle/northernspy which is essentially the same thing as we saw with the Edmonds one, right? Well, that’s not exactly what we want so what we’ll do here is we’ll add the month num to the beginning of this so that we have a more efficient searching system for WordPress. Especially in a site like this you know, where you can end up with thousands of posts, you definitely want a date number at the beginning of a post URL. If it’s not in there then WordPress can take forever to find the right post. So we have month num and then Edmonds. And then in between that, we will add category right there after Seattle… we’ll add category and then Seattle. We’ll save these changes and now the category name is going to end up before that. So let’s see, we can close that one and we can close this one but we’d come to Seattle and we hit view. And now you can see that we have the month number 07 which is when this post was published. And then Seattle apples red apples and then northern spy…so now you have entire category hierarcy laid out here and so that red apples is a subcategory of apples and if we instead go over to the Edmonds News and we pick one that doesn’t have a subcategory like rainier sweet cherry. Now you have Edmonds, cherries, rainier sweet cherry.
Okay so this is a permalink structure that is very SEO friendly. People can tell you know, what each of these things is going to be about by reading this and Google can tell what it’s about by reading this. And so this is a much better system than a system without that permalink control.
Okay and so then the next thing for us to do is to create a page where we can actually see this…where we can look at the Seattle page and it’ll show us all of the posts for Seattle. And that’s going to require a little bit of coding and let’s see…
Douglas, I’m going to turn you on here. Okay since you’re on audio pen, can you log in to that? Can you log in to that? I kind of like you to turn your phone on here so we can chat now about this. Okay well, okay. So are you there Douglas?
Douglas: Okay, yes I believe so. Yes.
Rick: Perfect. Okay, so did you follow what I was doing there?
Douglas: Yes, that made sense.
Rick: Okay so we have custom post types. A custom post type for each of the communities so any community related post is going to be created under the custom post type so you know, if I could add one here and that is let’s just say, weekend event. Subtext… and then let’s say, in the bananas category and we publish that and then go back to Edmonds. Now you can see we’ve got this weekend event here inside the category bananas and if we view it, that’s what we see. Edmonds bananas weekend event. And so what you’d have is categories for the different types of posts you would use, right?
Rick: What kind of categories do you think you would use? Can you give me a couple of suggestions?
Douglas: Schools, maybe. Or churches, neighborhood festivals.
Rick: Right. And you’d have those…
Douglas: Weather closings and stuff like that? Yeah.
Rick: Yeah and you would have those in… they would be across a given community that is, both Edmonds and Seattle would have churches and schools and those kinds of things, right?
Rick: So then when you’re doing that, when you’re creating a category… well, if we just go to… actually, any one of these category things is going to take us to categories which can be used under posts and under our custom post types. And so if you create…wasn’t that interesting? My apples… let’s see. That’s so funny. My apples category seems to have gone away. The subcategories under apple seems to have gone away which is a little odd. I may need to refresh that because if I pick one of these, I still have that over here. That’s so odd. You know, it’s probably a function of having transferred these categories over from another site. And so I wouldn’t take that as being a problem associated with what you’re doing. It’s probably just a little problem associated with me adding…oh, I see. So this is under Edmonds News. So now you can see that now my red apples and yellow apples and green apples do show up under here… under Edmonds News, under Categories. Yeah, now they do. It’s interesting though that they don’t necessarily show up as… oh yeah. Their parent apples is their parent. So I’m not quite sure why the UI is fooling around with this but it certainly is. It’s really odd. Okay anyway, that’s off topic.