This WordPress plugin enables the automation of creation of form element user interface for entering Post’ custom field. User will specify the form input type, the subject, and available options (when applicable). The corresponding form elements will automatically appear in the Write Post page.
Installation
Unpack the file rc-custom-field-gui.zip and upload the folder rc-custom-field-gui to wp-content/plugins/. Activate from WP’s Plugin Management page.
Configuration
This plugin supports the following types of form element: textfield, checkbox, radio, select, and textarea. To specify the custom fields, edit the file conf.ini.
Each entry begins with the subject inside square brackets. The second line specifies its type. The third line, which only applies to type “radio” and “select,” enumerates the available options. Each option has to be separated by a hash mark (#). For type “textarea”, “rows” and “cols” will specify, respectively, the height and width of textarea. The following are sample entries in conf.ini.
[Plan] type = textfield [Favorite Post] type = checkbox [Miles Walked] type = radio value = 0-9 # 10-19 # 20+ [Temper Level] type = select value = High # Medium # Low [Hidden Thought] type = textarea rows = 4 cols = 40
The custom fields’ values can be displayed with the regular method or with the help of appropriate plugins.
Screenshot







Pingback: davidbisset.com » Wordpress Custom Field GUI
hi Joshua.
your custom field plugin is very useful.
i have add a date selection field. it creates a unix timestamp in the meta data. you can put it into your official distrubution.
the configuration is also very simple:
[Display until]
type = date
start = 946681200
end = 1262300400
best regards
johannes schäfer
and here comes the code:
function make_date( $name, $start, $end ) { $title = $name; $name = 'rc_' . rc_custom_field_gui::sanitize_name( $name ); if( isset( $_REQUEST[ 'post' ] ) ) { $value = get_post_meta( $_REQUEST[ 'post' ], $title ); $value = $value[ 0 ]; } $years = range(date('Y', $start), date('Y', $end)); $months = array(); for($i = 0; $i!=12; $i++) { $months[] = date('F', $i*60*60*24*31); } $days = range(1, 31); $out = '' . '' . $title . ': '; $out .= ''."\n"; $out .= "Day\n"; foreach($days as $day) { $out .= "$day\n"; } $out .= ''."\n"; $out .= ''."\n"; $out .= "Month\n"; foreach($months as $month) { $out .= "$month\n"; } $out .= ''."\n"; $out .= ''."\n"; $out .= "Year\n"; foreach($years as $year) { $out .= "$year\n"; } $out .= ''."\n"; $out .= ''; return $out; } function insert_gui() { $fields = rc_custom_field_gui::get_custom_fields(); $out = ''; foreach( $fields as $title => $data ) { if( $data[ 'type' ] == 'textfield' ) { $out .= rc_custom_field_gui::make_textfield( $title ); } else if( $data[ 'type' ] == 'checkbox' ) { $out .= rc_custom_field_gui::make_checkbox( $title ); } else if( $data[ 'type' ] == 'radio' ) { $out .= rc_custom_field_gui::make_radio( $title, explode( '#', $data[ 'value' ] ) ); } else if( $data[ 'type' ] == 'select' ) { $out .= rc_custom_field_gui::make_select( $title, explode( '#', $data[ 'value' ] ) ); } else if( $data[ 'type' ] == 'textarea' ) { $out .= rc_custom_field_gui::make_textarea( $title, $data[ 'rows' ], $data[ 'cols' ] ); } else if( $data[ 'type' ] == 'date' ) { $out .= rc_custom_field_gui::make_date( $title, $data[ 'start' ], $data[ 'end' ] ); } } $out .= ''; echo $out; } function edit_meta_value( $id ) { global $wpdb; if( !isset( $id ) ) $id = $_REQUEST[ 'post_ID' ]; $fields = rc_custom_field_gui::get_custom_fields(); foreach( $fields as $title => $data) { $name = 'rc_' . rc_custom_field_gui::sanitize_name( $title ); if( $data[ 'type' ] == 'date' && $_REQUEST[$name.'_year'] != 0 ) $meta_value = strtotime($_REQUEST[$name.'_day'].' '.$_REQUEST[$name.'_month'].' '.$_REQUEST[$name.'_year']); else if( $data[ 'type' ] == 'date') $meta_value = ''; else $meta_value = $_REQUEST[$name]; if( isset( $meta_value ) && !empty( $meta_value ) ) { delete_post_meta( $id, $title ); if( $data[ 'type' ] == 'textfield' || $data[ 'type' ] == 'radio' || $data[ 'type' ] == 'select' || $data[ 'type' ] == 'date' || $data[ 'type' ] == 'textarea' ) { add_post_meta( $id, $title, $meta_value ); } else if( $data[ 'type' ] == 'checkbox' ) add_post_meta( $id, $title, 'true' ); } else { delete_post_meta( $id, $title ); } } }hm, what to …
wordpress eats all my html-tags.
if you are interessed on the code, you can send my a email.
bye.
Thanks for the plugin! Johannes, could you please send me an email with your addition if you see this? I can be found at sonoflee [at...] gmail [dot...] com.
Please also send me the addition at e[at..]ik2[dot..]us. Thanks!
This is amazing plguin, a very good job, but I’m wondering when it will be updated for WP 2.0? It seems that when I go back an edit an older post, the custom fields get reset to the first character of what was in the field before. Any ideas?
Jonathan,
This plugin is compatible with WP 2.0.
Did it ever work properly before?
Does the problem only occur when you use custom field of type “textfield?”
Do you not have a problem with WP’s built-in custom field interface?
Try disabling all other plugins. One/some of them may interfere with mine. Let me know if you know which one(s).
Pingback: André SC » Blog Archive » New media and art
Thanks, Joshua, fantastic plugin!
Re custom fields resetting to first character with WP 2.0 -
Here’s the details to duplicate the error, hope someone can find a fix for it:
1/ Set permalinks to anything other than default (eg ‘Date and name based’)
2/ Edit a post via an ‘edit’ link on an Archive, Category or the actual post page (doesn’t seem to be a problem when editing a post from the index/home page)
It’s probably right in front of me, but is the plugin set up to deal with defaults?
[Rating]
type = select
value = 9 # 8 # 7 # 6 # 5 # 4 # 3 # 2 # 1
I’d like it if the submitter made no adjustment to be able to define the value.
[Rating]
type = select
value = 9 # 8 # 7 # 6 # 5 # 4 # 3 # 2 # 1
default = 5
Thanks.
Darrell,
Just for you, can you test a new version that supports default value for fields of type checkbox, select, and radio?
http://rhymedcode.net/?dl=rc-custom-field-gui-1.2.zip
If you upgrade, take care not to overwrite your existing conf.ini
Sample conf.ini:
If you don’t desire any default value set, just omit the entire “default” line.
Let me know if you have/don’t have any problem with this new version.
Joshua, that works great. No issues with it. You’ll undoubtedly want to add something to the readme.
Also, `’Select’;` — I wonder if this is necessary if a default is included?
Left field question: Any quick and dirty way of inserting info, a url for instance, into the generated form from a bookmarklet?
Guess those backticks didn’t work. Rats.
One more thing. I don’t know how far you plan to extend custom-field-gui, but I can see a need for being able to control the size of textfields.
[Article URL]
type = textfield
size = 75
25 is a nice default, but having more control over this aspect would be a nice addition, too.
Darrell,
Yes, “Select” will stay; it means, “I don’t want to select anything.”
Anyway, here’s another version that will allow you to specify size for field of type textfield. Test it out for me, would ya.
http://rhymedcode.net/?dl=rc-custom-field-gui-1.2.1.zip
Pingback: André SC’s PixelPLEXUS » Blog Archive » David Krut Publishing on WordPress
Joshua,
It worked. Thanks for that small addition.
Here’s something I noticed. The first conf value, when inserts are made into a table produce values like, “7″ and “3″ but the latter produce field values are inserted as ” 7″ and ” 3″…minor I know, but it was something I noticed. Might be useful to note the use of the delimiter and spaces in the readme.
value=9#8#7#6#5#4#3#2#1
value= 9 # 8 # 7 # 6 # 5 # 4 # 3 # 2 # 1
Joshua,
This is fantastic for a newbie like me…thanks.
One problem though…my items are being ordered alphabetically, although they are not alphabetically listed in the conf.ini file. Since they are published as an “unordered list”, what is causing them to be ordered by alphabet? More to the point, how can I change this?
Also, a side note for other newbies…the plugin did not display on the published pages until I added the meta template tag to my templates (as with the WP built-in functionality)…I had assumed the plugin would take care of that.
Wow, what an incredible plugin, thanks for developing it! Very handy! One more thing: I tend to use more custom fields on my PAGES, and not only for POSTS. Is this functionality already there and I overlooked it, or could it be easily added, pretty please?
djchuang,
I believe someone provided the solution for you somewhere in a commment in this site. See if you can find it. Let me know if you can’t.
You’re right, thanks for pointing me in the right direction. I’ve added solution to this thread for others’ convenience — to add the GUI on PAGES too, add this line to rc-custom-field-gui.php :
add_action( ‘edit_page_form’, array( ‘rc_custom_field_gui’, ‘insert_gui’ ) );
I love your website. It has a lot of great pictures and is very informative.
Hi Joshua
What a neat little plugin. However I am curious to find out if there is a way to display the fields in the order they appear in the config.ini file.
Hi…
Love the plugin. I have one request tho. How can i make this work for writing new pages as opposed to posts? I use my wordpress as a cms and write pages all the time with specific meta data that i would love to be able to input at the time of writing.
Thanks in advance.
Cheers
chris
Does djchuang’s #20 above answer your question, chris?
Hi, thanks for the awesome plugin!
My cofig file reads as follows:
[Start-Up Cost]
type = select
value = Very Low # Low # Low Medium # Medium # High Medium # Low High # High # Very High
[Potential Earnings]
type = select
value = Very Low # Low # Low Medium # Medium # High Medium # Low High # High # Very High
In the admin section the order of these two fields mirrors the cofig file with Start-up costs first and Potential earnings second.
For some reason the order is reversed when I publish the post with Potential earnings first!
Do you perhaps know what could be causing this.
Thanks!
Andrew
Hi, this has lots of uses! thanks a lot!
I love this plugin but really need a way to display the fields in non-alphabetical order – I need them to be in the order I’ve used in the confi.ini file. Any way to do this?
Okay, for anyone else with the same problem, you can order the custom fields using the coffee2code plugin: http://www.coffee2code.com/archives/2004/06/30/plugin-get-custom/
It seems (from some initial tinkering) that the two plugins complement each other nicely.
Is this plugin working with WP 2.1.2? I’ve installed it but nothing shows up..
Manne,
I accidentally uploaded some wrong package recently. You may want to download it again. Let me know if you still have a problem.
I am getting an error message on the Write Post screen:
Fatal error: Call to undefined function: wp_create_nonce() in /home/timeless/public_html/wp-content/plugins/rc-custom-field-gui/rc-custom-field-gui.class.php on line 150
I am using WP 2.0.2. I thought this was for that version, but the last comment made me wonder. If it is still available, I would really love to have the right version. Thanks!
wp_create_nonce()is a fairly new function, so, you probably need to upgrade your WP installation.Thanks for the info, Joshua. That’s disappointing! Hm… I wonder if you might consider keeping the 2.0 legacy version available for those of us who really can’t upgrade? Or at least making it available upon request? I’ve noticed many plugin developers do this, because some of us built elaborate site on 2.0, and upgrading would break many good, solid plugins which aren’t available for 2.1 yet. If you don’t want to publish it, I would sure appreciate it if you would email it to me. I have been looking for this feature for ages. :)
kalico,
Either one of these; I forgot which one.
http://rhymedcode.net/?dl=rc-custom-field-gui-1.4.zip
http://rhymedcode.net/?dl=rc-custom-field-gui-1.2.1.zip
Just remember, if you ever upgrade your WordPress to 2.1 or later, upgrade the plugin as well. These old versions of plugin will do massive damage to your blog in WP 2.1.
BLESS YOU!!!! It’s perfect. It is EXACTLY what I have been needing. For the record, 1.2.1 is the correct version for WP 2.0. Thanks for the advice on upgrading. I will make a particular note of it.
Thanks again. I just can’t express how helpful this is for our site, and solves an issue we have been dealing with for a long time. Thank you, thank you, thank you!
It might help someone if I add in here the code I used to display the field contents. We needed something VERY simple for a post’s subtitle, but more convenient for authors than how WP has set up the custom fields. So here is how I display a subtitle on a single post page:
`
Hm…sorry to do this again, but the post did not show my code. I will try once more, but if it doesn’t work, you’ll have to tell me how, or else not worry about it.
I tried the latest package (version 1.5 and not 1.5b that I had tried before) but still nothing shows up on the posts page. Any ideas?
Manne,
Did you rename conf-sample.ini to conf.ini?
Joshua: Oh no, I totally missed that! Thank you for fast replies and a great plugin!
Great plugin. To my custom-field-gui I have added a [multiple select] and [date] field selectable though javascript calendar. If you are interested to add to a next release, I can send you the code.. drop me a mail.
I am finding more uses for this plugin every day! Is there a way to change where in the Write Post admin page the custom fields show up? Thanks!
kalico,
Like, where in the Write Post page you want the custom fields to show up?
I would like to move it just below the “title” and above the content of the post. Well, ok…. in an ideal world, I would really like to control the location of each of the custom fields separately!! But I will settle for being able to move all of them to between the title and the content. :) Can it be done?
Pingback: jeroenonstenk.nl : Wordpress CMS-tool 3: review de postvrijheid
I would love to move the custom fields below the title and above the content just as kalico suggested. That would be awesome.
Pingback: agyampark · wp plugin karnevál
Pingback: Stefan Hayden » Blog Archive » The wordpress Custom Field GUI is great.
Hi, I really like this GUI, and I would love to be able to use it, but it does not appear to be working for WordPress 2.2.1 (as of August 2007). Any advice? Thank you.
This bit: add_action( ‘edit_page_form’, array( ‘rc_custom_field_gui’, ‘insert_gui’ ) );
doesn’t seem to work on 2.2.2, are there any known compatibility issues with other plugins? I’d really like to get this to work.
It works fine on the “write post” page, but not on “write page”.