Title: Add plugin options
Last modified: August 30, 2016

---

# Add plugin options

 *  [ThreadPasser](https://wordpress.org/support/users/threadpasser/)
 * (@threadpasser)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/add-plugin-options/)
 * I’m writing a plugin and I’ve added an options page to set my options via the
   settings API.
 * I just added one quick option as a proof of concept and all seems to work fine(
   never coded anything for wordpress before).
 * Now I want to do something different. I want to generate an option for each post
   in a certain category. Let’s say “colors”. I have three posts in there. A post
   about blue, one about red and one about yellow.
 * What I’m trying to achieve, is some kind of interface in the options page that
   says “add row”. I click this button and an option row appears with a select box
   containing the three pages (blue, red, yellow) and a text field next to it to
   define the option.
 * Next time I click the plus button, only two of the remaining pages should be 
   in the select box, because one option is already defined… is something like this
   possible somehow? Are there wordpress functions to do this easily? Or are you
   aware of any existing code that I could study with a feature like that? My aim
   is to learn how to do this so any pointers would be relevant and helpful. Thanks
   for your time, I appreciate it!

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/add-plugin-options/#post-6558071)
 * It is possible. It would need to be done using JavaScript, and with jQuery pretty
   much built-in, I’d suggest looking at that.
 * The basic idea behind it is that you’d set up an array of available values, and
   when the user clicks the ‘Add’ button you take away any selected value and output
   a drop-down with only the reamining values.
 * I don’t know if anything that’s pre-built for this, but even though it’s not 
   a small job, it’s also not to bad, and it won’t seen quite so scary once you 
   start off with it.
 *  Thread Starter [ThreadPasser](https://wordpress.org/support/users/threadpasser/)
 * (@threadpasser)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/add-plugin-options/#post-6558127)
 * Yeah jquery seems to way to go. Too bad there’s no tool/framework to generate
   this code. Perhaps it’s a closely guarded secret amongst all the “pro” plugin
   writers. 😉
 * Other suggestions still welcome.
 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/add-plugin-options/#post-6558174)
 * There’s no “pro” plugin writers. Just people that have gone through it all and
   learnt along the way. 🙂 That’s one of the main reasons that people here, and
   other places, will give you tips and hints on what to do and where to look, but
   not actually straight-out give you a block of code to do what you want. It’s 
   because if we did it that way no one would ever learn how to do it themselves.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/add-plugin-options/#post-6558199)
 * There’s no framework for this because writing this sort of code really is fairly
   straight forward. When learning, it will still be a struggle. In the end, you’ll
   be surprised how little is actually involved.
 * TL;DR – If you can’t learn for yourself for any reason, help out a struggling
   coder 🙂
 * IMO, learning by doing really is the best way, and that is in part why I don’t
   provide code here, only advice and opinion. In a sense there are ‘pro’ plugin
   writers if you define pro as anyone who does something for pay (it’s not that
   simple in reality). There are very few who can make a living this way, even then
   they are not getting rich this way.
 * There are many more who are struggling, and while it is just supplemental income,
   it can be essential to make ends meet. It is for these people why I don’t provide
   code here. I don’t wish to take away from someone where a bit of coding income
   is very important to them.
 *  [RossMitchell](https://wordpress.org/support/users/rossmitchell/)
 * (@rossmitchell)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/add-plugin-options/#post-6558205)
 * My advice here is to use either javascript or jquery as suits your experience.
   
   Google is your friend, use it to search for plugins which fulfill specific questions.
   Download and study plugins, as many as you need. If you have specific problems
   or questions then start a thread, provide as much detail as you can and give 
   it a good title.
 *  Thread Starter [ThreadPasser](https://wordpress.org/support/users/threadpasser/)
 * (@threadpasser)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/add-plugin-options/#post-6558211)
 * The problem I also have with studying plugin development, is the fact that there
   aren’t a lot of good tutorials that use proper coding technique. Or if I find
   some tuts, I feel that they are outdated or try to re-invent the wheel (don’t
   use built in functions for security). Also, when I study code of plugins, various
   techniques are used (singleton pattern, functions.php hacks, plugin “the wordpress
   way”, fragmented code, etc…).
 * I’m trying to make the best of it, for my own peace of mind, for easy maintenance
   later. That’s why I ask for useful pointers if you know any existing tools for
   this task.
 * But yeah don’t get me wrong please. I’m not afraid to do it myself, because trust
   me I will. I’m certainly not looking for blocks of code. Still I feel it’s useless
   to code something from the ground up if there is an elegant way to do it by using
   built-in wordpress functions.
 * Looks like there is no such thing for my requirements, so yes, I’ll look at jquery
   indeed. 🙂 Thanks for your answers so far.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/add-plugin-options/#post-6558224)
 * There really isn’t a “proper” coding technique that should be applied for any
   project. There’s many who will say their way is the right way, but it’s a matter
   of opinion. Who’s to say what is elegant and what is ugly? Code can be elegant
   and clever but difficult for others to follow the logic. In my mind that is not
   good coding. You’ll eventually develop your own style for what works for you,
   that will be your proper way.
 * That only comes with time and experience. What’s one to do in the mean time? 
   If you’re working mainly with WP projects, you can start with [WP Coding Standards](https://make.wordpress.org/core/handbook/best-practices/coding-standards/).
   Assuming you haven’t yet looked at this, you’ll find there is still a lot of 
   latitude within the standards, they do not necessarily prevent one from doing
   some rather awful things. It’s more just an accepted style so all core code has
   a cohesive appearance. Ya gotta start somewhere 🙂

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Add plugin options’ is closed to new replies.

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 7 replies
 * 4 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [10 years, 8 months ago](https://wordpress.org/support/topic/add-plugin-options/#post-6558224)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
