 We are dealing with an open API that's going to have 22 districts and in each district there's a constituency, sub counties and thereby we go to parishes, then we'll go all the way down till we get to the villages that we do have. Now this can be quickly be shared by having what will be having our custom post type that has a village and this village is classified and a district and the district is classified and a sub county and then we'll have a sub county then a parish and the sub parish which eventually gives us a village. So at the end of the day we'll be able to expose districts, counties alone and we can separate the concern by having this but WordPress by default gives us this possibility to categorize the different things that we're going to be working with. So I'll quickly jump into our editor and we're going to be using our taxonomy, we're going to start afresh from here if we reload. So we have a new village and we are now ready to add a taxonomy so I'm going to go to if you look up this functionality of a registered taxonomy on the codex of WordPress you'll find that you have all the information that's needed here for you to understand what it's all about. So you'll find out the different post types that are registered by WordPress by default, the levels that are needed. We are going to look at the example that we are given of how to register a taxonomy and I'll just copy all this code and place it here then I'll explain what it's all about. Then I'll just move this add function to the bottom here so that the PHP will read the add action after having processed this functionality. So we have a function here which we shall call create village taxonomy and basically what's happening is whenever we're going to WordPress and initialize it we run this function called create village taxonomy. What it will do is that it will register taxonomy whose name is a district and it's attached to a custom post type called villagers and then it has a label meaning that its name will be district and a slag of district. So when I save this I'm able to actually go into my village and refresh and we'll see that we have a new district here. And previously I had set some districts in here like Gulu and Kampala, that's why you're seeing this information showing up here. And if actually you can attach a number of other categories like you see how we have this, I'll just open this up for our preview. But if we decided to say that we're going to change this to be attached to the post type, if we reload our post type we'll see that we have the district categorization here and it's no longer with our villagers but it's attached to the post. So that's why the particular custom post type name is very important. So for us to create all the other categorizations that we do need we're just going to copy this over and then we'll change what needs to be. So we're going to change the district and then we're going to change this to county. I'll just put this in our case and then I'll have this particular label in up the case. So these marks that we see here help us change languages. Let's say we've written this in English and then we can actually internationalize it to French or German by using these marks here. You can read about them in I-18N in the word press codex and then we're going to go for these other ones. We have our five taxonomies that are registered if we reload right here. So in our custom post type we find we have the district, county, sub-county, parishes and sub-parish ready for us. And if you look here on the side you will see that these are available. So what I'm going to do is I can actually drag them in order so that when someone is feeding in the information they are not lost. So I'll just move this down to just above parish. Then I can always send the publish up up or at the bottom so that someone only clicks publish after they are filled in this information. So I'll just move the sub-county also up so that it is in position when someone is inputting all that information. So we are ready to start taking in our information and we are ready to actually push it at our front end or we can be now ready to push it to our custom endpoint. Anyone of us can actually put information in this so I'll be looking forward to adding that. So by now you should have realized that we have the same thing that is that is repetitively coming up. So what I'm going to do is try to refactor all this code so that we have something that's a little neat. So I'm going to save our taxonomies in a variable called tax and then I'll create an array of this. So in our array we are going to have our names that we do want. So we want to have a district then we want to have a county. We want to have a sub-county then we want to have a parish. Those are the five pieces that we do need. So what I'm going to do here I'm going to wrap them under a four each loop. And I'll say for each tax as a taxonomy I'm going to look over and say register one taxonomy. So I'm just going to get one of these and then I'll get rid of all the others. So in here I'm going to place a register taxonomy so the first thing that I'm going to do is get the taxonomy here registered. Then I'll also just register this as taxonomy and allow for space. Of course internationalization only allows directly added values. So once we are done with this we're going to go and reload in our browser and when we reload in our browser we actually find that we don't have any issues in our particular categories using the taxonomies. Apart from having this in lower case and then we have an underscore. So I would like to have both words in upper case. So what I'm going to do is I'm going to use a PHP functionality which is called a string replace. And basically it's going to search our taxonomy that we've stored in the variable. And it requires three arguments. So the first argument is what you're looking to replace which is underscore. And then what we'll replace is with a space. So I'll put a space here and finally the string where we want this to be done. So if I save this and just go back and review we'll see that that string we have that space coming in and longer have the underscore coming in. But when we look at the bottom of right here at the bottom we'll see when we look at that URL we'll find that the taxonomy part has its underscore. However the label here is clean. So what we need to do is also make it uppercase. So what we're going to do is use also again PHP function uppercase. This one will get the first letter of the word and we'll make it into uppercase. So we have this all coming out on reload. But we still need both of them. So what I'll do is instead of use uppercase you see first our user you see words which will get the first letter of each word and then make it uppercase. So we have what we wanted actually in here. So the only thing that now is still probably a pain point is that when we go in the districts or in the counter itself we see this is changing well. But however this word category is still here. We still have parent category. We still have categories in here which can be a bit confusing for the people entering our data. So we're going to go to our custom post types because the labels that are needed are similar. So we'll just pick the labels and we're going to come and drop them in our for each loop. The next thing that we're going to do is we're going to pick our label that we had worked out very well and we're going to start it into a variable with the name of name and then we'll just terminate that. And what we'll do next is replace all our plural name variables with a variable of name and then also get all the singular name variables and also turn them into name. So we're going to change our label also into labels and when we refresh and reload the page we see that we have an error. We're receiving an array of information and yet this particular label only accept only one item. However if we want it to be an array we'd have to change this to labels. So on reload we realize that everything is fine we have counting the places it should be apart from the parent category. So what we need to do is change that when we go back into our code we realize that it should be parent item instead of parent. So when we save that and refresh and reload we'll see that parent count is actually our new label. This is what we needed to have all our taxonomies ready so we're going to be able to put our information in our villages and then we'll start querying it and then sending it onto our API endpoint. If you like this video please give it a thumbs up or if you haven't subscribed to the channel please subscribe so that you don't miss any updates that will be coming on this channel. We shall be doing more work and we shall be able to open sourcing this particular project for any person to use. Thank you for watching. Bye bye.