This is the fourth in a series of live lessons on using WordPress and Thesis as a Multilingual Content Management System (CMS). In this lesson we create the custom post meta we need using the Verve Meta Boxes plugin. We’ll be using this custom post meta to enable language switching.
The Verve Meta Box Plugin is no longer available. As a replacement we are suggesting the Types Plugin.
So what we’re going to do is come over here, down here to plugins. Actually, we’ll go to Add New and we are going to search for Verve meta boxes. Search the plugins, install the plugin, activate the plugin. And then what we’ll do is scroll down here and create our meta box. And so under Tools, Verve meta boxes, we’re going to create a new meta box and we’re going to call this new meta box language options and we’re going to apply this meta box to a page only.
So now we create the box. Okay, we’re going to have 2 different fields. The first one is going to be the page language and under our field description which in this case, is the like a little tool tip that pops up. We’ll just say… actually, it’s going to be a select box, that’s true. We’re going to turn that from a text box to a select box and we’re going to say, “Select the appropriate language from the list.” Okay, we’re going to add that field and then because it’s a select box, we’re going to click here and add our values. So we’ll start off with English, French… each of these values need to be separated with a comma and a space. French, Spanish, and Italian…okay, and then once you’re done, you just hit enter and that saves those.
The next part is going to be a text field and we’re going to call that page key. Let’s see, enter a… I want to say unique page key but I want to… I’m going to enter a number to be used in each corresponding page. Add the field. Hopefully that’s straightforward enough. And then what we’ll do is we’ll update this box. Now, what we do is we go over to our pages and we come over here to English home and look at our page language and our page key. The English home, we’re going to select English as our page language and since this is the homepage, let’s just put the number 1 in there. Now if you hover over this, you can see the tool tip that pops up at the appropriate language on the list and enter number to be used in the corresponding page. So if we select those and hit update and we go back to pages… and actually, I’m going to do this the easy way. Open this in a new page and then we’ll open the French page in a new tab and the Italian homepage in a new tab and the Spanish homepage in a new tab. So this French, so we’ll select French. The page key is still 1, we’ll update it, we’ll close it and then this one is Italian… page key is 1, update it and close it. And then this final one is Spanish, page key is 1, update it.
Okay now we’re going to do the same thing with the 5 reasons. So we’ll say open the English one in the new tab, open the French one in the new tab, open the Italian one in the new tab, and open the Spanish one in the new tab. So here we are at English, select English. We’re going to make that a page key of 2, update… this one is going to be… what is this? This is the… that’s French, so page 2, update. This one is Italian, page 2, update and then this one will be Spanish, page 2, and update. Okay, so we can close those.
And then we’re going to do the final thing with the last one. So open a new tab, open a new tab… so we’ve got French, English… open a new tab and open a new tab. Okay, so this one’s English, select the language and make that one 3. Of course we could just…if we wanted to… show you how you can make that 350. As long as the key is unique, 350… update 350…oops, I didn’t select my language here. This is Italian. Okay, I don’t think I selected my language in the French one and Spanish. Update.
Let’s go back and look at the French one here for a second. Oh, French. Nope, I did not select French, update. Okay so there we go. Now we have entered all of those things and let’s just double check to make sure, let’s spot check this. Yeah, French and 2, okay.
And so the… now that we’ve accomplished this, the next part of this is going to be to create the logic for choosing. Remember that we talked about this logic a bit here where the page loads and it gets this page key which is, in this case, the number 1, right? Because this is English so there’s our page key so it loads and grabs that page key and then it goes out and loops through all of the pages and gets the pages that have that page key of 1 and then it takes the English post id and puts it in a variable. French post id, Spanish post id, and Italian post id and then puts them in their respective links. And that’s how the system is going to work and we are going to do that next week. Although I am posting the code for the language switching logic to the forum in the Live Answer code section…so if you want to look at the code advanced of next week’s lesson, you’re certainly welcome to. Otherwise I think it’s going to be a fun little project I’m enjoying working on and I look forward to working with you on it here in the future. We’ll just chat with everybody next week. Thanks a lot. Bye bye.