 Welcome back to the channel. In today's video, I'm going to show you how to make your own setting page, like what we have here in WordPress. Now, the reason I would do that is because I want to have general settings that I can use across my site. One of the things that you see is that WordPress has given you a site title, tagline, and a couple of other things it uses internally. But some of those you can see when you come on the front end, like this little tagline showing up in the theme, or even something that you can have in the footer here, showing what your business is all about. So let's jump into the video. I have advanced custom fields installed in my site, and I'm going to activate it. This will give me a new menu item, which is called custom fields. From there, I'm going to create a new field group. I'll click add new, and I'm going to say add footer settings. Now in the footer settings, I'm going to add a new text field, which I will call holding company. I'll click here in the field name to add that. It will be a text field as a type. There will be no instructions. It won't be required. And I'll just leave everything else as default as it should be. I'm going to close that. And then when I come to the locations area, I can choose to have a page, a page type, all these different options available. But in particular, I want to add an options page. So when I click select options page, it's going to tell me that no options page actually exist. So what I'm going to do for now, I'm just going to hit publish and go and create an options page for me to actually kickstart this off. Now what we're going to do can be done in the functions PHP, or you can actually put it as a plugin. Now the reason I would go for the plugin is simply because with a plugin, even with the change of theme, you'll still keep your content intact. But with a theme, if you change the theme, then you will lose your options page. So I'm going to open up my editor. I'll open up my website in the editor. I'm going to go to the WP content. I'll go into plugins and I'm going to create a new folder here, which I'll call take the options. And inside techie options, I'm going to create a new file, which I'll call techie dash options. And this can be any name that you want, not PHP. And I'll use a snippet in my editor, which I used to add all the comments that are required to help me start my plugin in WordPress. So I'll hit that, remove this space. And then I'm going to change the name and just say techie options. I'll change my plugin URL link to my GitHub. And then, of course, change this. I'll say ads and a CF options page. I'll change this to GPL too. And then I'll just copy this and use it as my text domain. So that will allow me to do any translations if I need to. The first thing always is to add some security checks and say, are we running this plug in the right way? So we shall use the apps path and find out is it defined. If it is not, then we're going to say die right here and pass in a message that says unauthorized access. So I'll hit save here. I'm going to go back to my plugins area. And then I will activate that new plugin. So go to my plugins. I'm going to activate great activate techie options. And nothing will happen because we haven't added any extra code to it. Now let's go back to our code. And in here, we're going to use a new function which is called SCF add options page. And with this function, it expects a couple of parameters. And since SCF is not a plugin that you always find on every installation, I'm going to run some if statements to check if this function actually exists. So I'll copy its name and I'm going to write up here and say if the function actually exists. And the function we are going to look for is the one that we have down below. And this function is the SCF add options page. Just correct that typo. Then we're going to have this function come in and run. Now this function has its parameters that it expects. For example, it expects to have a page name. It expects to have a menu name. It also expects to have things like is there redirect and so on. So it expects to have a page title. It also expects to have a menu title. The page title and the menu title are items that I'm talking about here. And the page title is usually what we have up here. And then the menu title is what we have here on the sides. So we're going to say the page title is actually equal to the greater than symbol. And then we'll map it and say the page title is going to be our footer options. I'll add a comma here at the end. And then we'll say our menu title is actually also going to be footer options. Now just add page here so that you can see the difference. Add a comma here. You'll see that our editor is starting to scrape at us. And that is simply because I forgot to tell it that this is actually an array. So I'll add the one array here. And then I'm going to close off that array at the bottom. Our editor was screaming at us because if we had these parameters that had arrow functions in them and it was not recognizing them. So the only way that can be done is by having a type of an array. So when I hit save on this, you'll see that the error warning goes away and we can actually save this. We can come back in here. We reload this and you'll see that we have a new option down here as footer option. And when we go to the field group here and reload this, you'll see that we have this new footer options page showing up. So we can be able to update this. And on updating that when we go to our footer options, you will see that we have this field that's available for us. So we can say we are a child parent to Google Incorporated. So I'll update this and you'll see that this field is actually served and we can use it on our page anywhere that we want. But before we use it on any page, I want to just go into a couple of the other options that you have available as settings for your. So in here, we can actually add a menu slug and say menu underscore slug. And this slug will be very, very usable if we ever want to have, let's say like a sub page. And by a sub page, I mean something like what we have here coming across these different menu items. That's a sub page. So I'm going to add a menu slug. Let's say our techie press techie options as a menu slug. I'll add a comma. We can have an option to redirect. And we are not going to be redirecting this anywhere. So I'll say this is false. I'll add a comma. We can add capabilities. And that simply means which kind of people do we want to see this menu? Do we want to have only administrators? Or is it people who can actually edit posts or do whatever item it is? So for now, I'm going to say administrator to only leave administrators as the ones who can see this page. Add a comma and save. And then I can also add a position. And basically I'm saying I want to move my menu from the bottom and move it up. So I'm going to choose a value like 5.4, which will allow me not to clash with any of their menus because all these menus have values that are whole numbers. So if you add a decimal point, that will allow you not to clash with any of these items. So I'm going to reload this page. And you will see that automatically advanced custom fields had given us a particular slug before. And that's why this page is inaccessible. So we are going to go back to our WP admin. And then when I reload that page, you'll see that our footer options has actually moved from down to up because of the position that we've given to it. So I'll click on the footer options. You'll see that our field group has disappeared. So we need to come back to custom fields, go and edit the footer settings, get our footer options right here and click update. So on updates, if we go back to our footer options, you'll see that our information is still available. Our field is here and we can update it. So you can have a number of the fields that you want to have. You don't only have to have texts, but in my case, I just wanted to have only this option. So this option is actually available for me to use on my theme. And I'm going to be able to do that. So I'm going to go back to my editor and I'm going to go into my themes folder. I'm using the 2020 theme. I'll go to the footer right here. And at this part where it says for add by WordPress, I'm going to duplicate this information. And then I'm just going to add my PHP right here. I'll remove all the other stuff and we'll write PHP here. I'm going to say echo and the function I want to use is called get field. And in get field, we're going to add two arguments or two parameters. The first one is going to be the name of our field. And that name of our field actually comes from what we have inside our custom fields. I'll go to edit options. And you will see that the name is what we have here as holding company. So come back down to my code best holding company there. Then we have to add the word option right here. So I'll save this. I'm going to come back to the front end of here reload. And you will see that we have this information right here. So your client doesn't have to always go and search for wide for options like this. They can always just come to this selection and changes and say maybe now we've been bought off by Facebook. So once they have updated that click updates button here to save the changes. Come back here, reload this. You'll see that it automatically reloads. So without writing so much code, you have all this information available for you and it can be reusable. I'm going to add one extra subpage to this just to show you how it's done. So I'll come back to my editor and I'm going to go to this section where we added our options page. So I'll duplicate all of that and I'm going to make a few adjustments. The first thing is I'll remove the redirect, the capability and the position because all those other things are going to depend on what the parent page is about. So I'll change this and say this needs to be the parent slug because we're going to depend on this parent item. And I'll change this and say, let this be sub footer options page. Let this be sub footer options. And once I'm done with that, then I'll come here to and I'm going to add an underscore and say sub so that we have a CF add options sub page. So once we have that, I'll hit save. And then I'm going to come back here to the backend and reload this page. And you'll automatically see that now we have our footer sub page right here. And it expects to have its own field group and so on. Now, the reason we have these options footer options showing up here is because that's the way wordpress by default works. Whenever you have a new menu, it always will duplicate what you have here as a parent and make it as the first option. And I don't know why that is. Maybe they thought that whenever you go to the sub footer, you will want to come back to the main page. So that's the way you add a sub page in a CF. And one little tip that I'm going to share with you is that you need to always have your field groups available for you. So let's say someone came and messed up with your custom fields in here and maybe deleted your field group. That would be disastrous. The way you save yourself from that trouble is by coming to the tools in here. And then you go to the footer settings. We're going to generate a PHP code. We'll copy this information right here. Or we just simply click the copy to clipboard. We'll come back here to take key options. And we're going to pass this information down here. So once we have this and save this, we are good because what's going to happen is that if I come back here to my field groups, trash this and go even into that trash and just delete permanently. If we come back to our footer options, you're going to see that we still have this available. So SCF will use this code that is in our plugin and retain the fields and the options available for us for future use. So this is something that SCF solves quite easily and makes it a nice, clean, easy process for us to do. If you enjoyed this video, don't forget to give it a thumbs up. Share it with friends who are struggling or who don't have a clue. Maybe you want to give them something that will make their work faster. And don't forget to subscribe if you're new here. I have a lot of WordPress content that's going to come up and it will be good to share that with you. Otherwise, enjoy whatever you're developing.