FREELessons: 13Length: 1.7 hours

Next lesson playing in 5 seconds

  • Overview
  • Transcript

1.3 Using Existing Solutions

When it comes to using a theme options page, you have two choices: either code it from scratch, or use an existing framework or plugin. In this lesson I’ll show you two existing solutions that can get you up and running.

Related Links

1.3 Using Existing Solutions

When it comes to using a theme options page, you basically have two options. You can either code it from scratch, or you can use an existing solution, like a framework or a plugin. And in this lesson, I'm going to show you two existing solutions that can get you up and running as fast as possible. The first one is called WordPress Settings API, and it is made by Jeroen Sormani. I'm really sorry if I didn't pronounce that correctly. Basically what you do here is, you set a name for your plugin or theme. Let's say, for example, test-settings. It can use a plugin prefix if you want. Text domain for internationalization. It's for translating your WordPress code into other languages. You said the Menu position, where do you want the link in the admin to be placed? The link for accessing the theme options page. We can create a menu page, submenu page, options page. That's gonna put it under options, or not in the Menu. So let's just say Menu page. You hit next tab. And what this will give you is a drag and drop interface. And you can basically drag and drop various components here. Arrange them anyway you want, delete them if that's what you want. And once you're done grabbing all the fields that you need, you simply hit Let's go. Apparently, the plugin prefix is required. So let's say AP. Text domain, AP. That should do it. Let's go. All right. So what this gives you is the code that's required for creating the theme options page. You will paste this in your functions PHP, or any kind of PHP file that ultimately ends up in function PHP. And that's gonna create a theme options page with the settings that you just set. It's by far the easiest method to create such a page. Now the only downside is you're limited to these five types of fields. So if you wanna add something custom, you cannot do this here. Also, we don't have a lot of control over how these are structured, like if you want them to be in different sections, you cannot do this here. But If it's just a simple page, then this is the way to go. So, this is the first option. The second option is to use something called the Redux framework. And this is so popular, I've seen it being used in a lot of WordPress themes that are being sold on ThemeForest right now. Not only that, Redux is a framework that allows you to create your own theme options page. And I have a demo here opened. You can see just what kind of controls they have, right, from checkboxes to radios. Sortable items, right, you can drag and drop to change their order multi-text. The different editors, design fields like colors may have custom color controls here. What else? Dimensions, different input types here. Media uploads, gallery, you can upload your own images. Let's see typography. You can change the fonts here. You can choose different fonts, even Google web fonts. You can choose from those set different properties for those fonts, colors, and all that stuff. So it's a pretty complete framework. It's gonna take you, I tried playing with this awhile back and it wasn't very intuitive, right? Took me a while before I could start to understand how to use it, but once you do, it's really powerful. We can create pretty much any theme options page you want. This is free to use, its open source, people are contributing to it all the time, it's improving all the time. And from what I know, we can actually use this in your themes if you're selling them on ThemeForest, which is really great. And yeah, those are the two solutions I wanted to show you for using theme options pages. Now, if you think the first one is too simple, and the second one is too complex, maybe we can find some middle ground between the two. And we'll do that in the next chapter where we'll start to code our very own theme options page from scratch. So I'll see you in the next lesson.

Back to the top