Title: [Plugin: Custom Field Template] Populate dropdown / tickbox options dynamically (using PHP?)
Last modified: August 19, 2016

---

# [Plugin: Custom Field Template] Populate dropdown / tickbox options dynamically (using PHP?)

 *  Resolved [lunarartist](https://wordpress.org/support/users/lunarartist/)
 * (@lunarartist)
 * [17 years, 6 months ago](https://wordpress.org/support/topic/plugin-custom-field-template-populate-dropdown-tickbox-options-dynamically-using-php/)
 * First things first: excellent plugin development. It’s full of potential, and
   easy to implement… top job. 🙂
 * Now, I’m trying to work out a way to define the options of a select / checkbox
   set using values that are contained elsewhere in the database.
 * For example, if you have a list of locations as Pages, and you then want to create
   an event that is to occur at one of those locations, there should be a ‘Location’
   custom field which would have a list of options based on the location pages available…
 * Is there any development that would allow these options to be gathered through
   a standard query? (Is there an established method for executing PHP within the
   template options of this plugin?)
 * I’ve yet to look at the plugin code thoroughly myself (I’m not particularly skilled
   with PHP anyway…), but I thought maybe this functionality was already being looked
   into elsewhere…
 * Many thanks in advance for any assistance.
 * [http://wordpress.org/extend/plugins/custom-field-template/](http://wordpress.org/extend/plugins/custom-field-template/)

Viewing 1 replies (of 1 total)

 *  [Hiroaki Miyashita](https://wordpress.org/support/users/hiroaki-miyashita/)
 * (@hiroaki-miyashita)
 * [17 years, 6 months ago](https://wordpress.org/support/topic/plugin-custom-field-template-populate-dropdown-tickbox-options-dynamically-using-php/#post-916597)
 * I released the version 0.6.4. You can use PHP codes in order to set values of`
   radio` and `select` types. (I am sorry that you can not use php codes in `checkbox`
   right now.) See the option page.
 * This is an example to show a select list of post titles under a certain category.
 * —- Template
    [posts] type = select code = 0 —-
 * —- CODE# 0
    $values = array(); $posts = get_posts(‘category=1’); foreach($posts
   as $post) { $values[] = $post->post_title; } —-
 * Basically, you need to set $values as an array. you can also set $default also.
   Here is an easier example.
 * —-
    $values = array(‘dog’, ‘cat’, ‘monkey’); $default = ‘cat’; —-
 * You can set any values by using your own code. However, do not forget to do it
   at your own risk.
 * I hope this option will work properly for you.
 * Thanks.

Viewing 1 replies (of 1 total)

The topic ‘[Plugin: Custom Field Template] Populate dropdown / tickbox options dynamically(
using PHP?)’ is closed to new replies.

 * 1 reply
 * 2 participants
 * Last reply from: [Hiroaki Miyashita](https://wordpress.org/support/users/hiroaki-miyashita/)
 * Last activity: [17 years, 6 months ago](https://wordpress.org/support/topic/plugin-custom-field-template-populate-dropdown-tickbox-options-dynamically-using-php/#post-916597)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
