More Fields (pre WP 2.5)

Attention! This information relates to More Fields 0.5 and below. See this page for current information.

This Wordpress plugin is a flexible solution to adding additional fields to a post. Any number of boxes can be created on the Write/Edit page, which hold additional fields that are to be associated with a post. These additional fields are stored as a posts Custom Fields.

A box is one of the elements that appers on the Write/Edit page, either on the larger left column, or the narrower right column. This plugins adds any number of boxes, with any type of field, either to the right, or the left on that page.

This plugin can be downloaded from here:
http://wordpress.org/extend/plugins/more-fields/

Table of contents

1. Options -> More Fields

The required boxes are set up in Options->More Fields.

Description of fields:

  • Title of box - This is the title at the top of a box - appearing on the blue background on the Write/Edit page. This title is also used when accessing the content of a box in a template.
  • Settings:
    • Include this box on the Write/Edit page - toggles whether or not this box is shown on the Write/Edit page.
    • Position left (else right)- sets the position of the box in either the left, or the right column. If positioned on the left, the box will be much larger than if positioned on the right. Having it positioned on the left is more appropriate when having textareas that are to contain lots of text.
    • Delete this box! - Removes this box from from the Options page and the Write/Edit page. The box will no longer be shown using the template function get_box(); . The settings must be saved (Update Settings) for the box to be removed.
  • Title - Sets the title for the field. This value is optional, which might be handy when creating a box with only one field, such that the title of the field really is the title of the box.
  • Key - This field is required. It is the name of the Custom Field that is created for this field. Using this key, a field can be echoed in a template using e.g. meta(key);.
  • Options - This sets the input type of the field. The following types of options are available:
    • blank - the default type of a one line textfield is created by leaving the Options field empty.
    • textarea - This creates a multi-line textarea.
    • E.g. 0:10 - Creates a select list with values between 0 and 10 in ascending order.
    • E.g. 10:0 - Creates a select list with values between 10 and 0 in descending order.
    • E.g. value1, value2, value3 - Creates a select list with values value1, value2 and value3.

Using the controls to the right of the field, it can be moved up or down in the list. The order that the fields appear in on this page is the order that they are returned in when using the get_box(); function

2. Template functions

There are currently two template functions supplied in this plugin.

  1. meta($key) - echoes the Custom Field with key $key.
  2. $var = get_meta($key) - returns the Custom Field with key $key.
  3. The more_fields action, prints out the entire content of a box.

3. Examples

3.1 Example one: Employee/member information

If you have company or organization and wisely opted for using Wordpress as the CMS, then you could create a page per employee/member (if you have a reason for doing so — this is mere conjecture). Say you want to create pages for this (as opposed to a post), one page per person.On the Write->New Post page, a section similar to this could be added:

em_admin.jpg

This is created the following way in Options->MoreFields:

More Fields Example 1

Note that the Position Left tickbox is checked and that the Show in Post Write/Edit is unticked. This box will only appear when adding or editing a Page.If you want to display only the biography in a page template:

<?php meta('ci_bio'); ?>

And you can store the value of the custom field to a variable using get_meta, e.g.:

<?php
  if ($bio = wptexturize(get_meta('ci_bio')))
  echo 'Resume: ' . $bio;
?>

Or to display this information as a ‘ul’ list with a ‘h3′ header inside a div called ‘employee_info’:

<?php
   $options = array('div' => 'employee_info');
   do_action('more_fields', 'Employee info', $options);
?>

If you still only want to display the bio, use the ’show’ keyword in the options.

<?php
   $options = array('div' => 'employee_info', 'show' => 'ci_bio');
   do_action('more_fields', 'Employee info', $options);
?>

Or, to only show the name and the position id a ‘dl/dt/dd’ list, with a ‘h3′ header:

<?php
   $options = array('div' => 'employee_info', 'format' => 'dl', 'show' => array('ci_name', 'ci_position'));
   do_action('more_fields', 'Employee info', $options);
?>

3.2 Example two: Geocaching/Geographical information

If you are a member of the geocaching community, then a blog post about a specific hunt for a geocache would require additional fields for latitude and longitude. On the admin page, something like this can be created:

More Fields Example: Geocaching

On the Options->More fields page, this is created in the following way:

More Fields Example 2

This can then be printed in a template as a dl/dt/dd list, inside a div called ‘geocaching’, by calling the following:

<?php
   $options = array('format'=>'dl', 'div'=>'geocaching');
   do_action('more_fields', 'Geocaching', $options);
?>

If you want to create a link to google maps (other brilliant map services are available, like Multimap)

<a href="http://maps.google.com/?ll=<?php meta('gc_latitude'); ?>,<?php meta('gc_longitude'); ?>">Google Maps</a>

The key that I’m supplying to the meta function is the key that i specify in the More Fields Options.

3.3 Example three: Wine blog

Say you’re writing about wine - and we all love wine, right? Additional information about the bottle of wine that is being written about will add value to the post - information such as grape, winery, and perhaps a score. One could construct a box in the admin like this:

wine_admin.jpg

I’ve filled it in just highlight that we’re creating selects. The setup in the More Fields Admin looks like this:

More Fields Example 3

Note that the Year range runs from 2007 to 1970 such that 2007 is listed first. The Score is a select between 1 and 10.

To retrieve the specifics about a wine reviewed in a post:

 <?php do_action('more_fields', 'Wine');?>

Or, to create a link to a page with one of the fields a as a parameters:

<a href="http://en.wikipedia.org/wiki/<?php meta('wine_type'); ?>">Wikipedia</a>

This method can be useful creating links for an affiliate program (e.g. Amazon Affiliate Program), generating revenue for your site. These affiliate links often include a search term, which could make the link relevant for your post.

3.4 Example four: Post specific CSS

By inserting CSS in the head of your templates you can alter the design of your Wordpress site on a post by post basis.

To create a field on the Write/Edit page where this can be inserted, configure More Fields in the following way

More Fields Example 4

Then, within the <head> tag of of your templates, insert this code:

<?php meta('extra_css'); ?>

For examples of this in use see this special on disco, compared to the normal look of the site.

4. Advanced use

More Fields provides an action: more_fields_admin when the plugin enters the building of the content of a widget, i.e. after the head with the title is built. You can use this to insert html, like special fields, e.g. based on the content of the post.A simple example using the above geocaching example - executing some javascript when a box is checked:

function p2m_meta_insert ($title) {
   if ($title == 'Geocaching') {
      echo '<input onchange="doSomething();" type="checkbox" /> Cache found?';
   }
}
add_action('more_fields_admin', 'p2m_meta_insert');

Which will change the top of the box to this:

More Fields Example: Geocaching - Using the action

The JavaScript is inserted using the admin_footer action.At dagensskiva.com we use the more_fields_admin action to insert a checkbox used to indicate whether a review is the review of the day one or an additional one. This tickbox triggers JavaScript that updates the post with the appropriate categories. We also insert three small select boxes (year, month and day), that enables the writer to set the date that the post will be the daily review for - this changes the timestamp settings, again, using JavaScript.

5. Language support

The .po file for the plugin can be found in its directory. Name compiled .mo files as e.g. p2m-more-fiels-sv_SE.mo where ’sv_SE’ is the language domain (here Swedish), and place in the same directory as the rest of the plugin files.

As of yet, the plugin is only translated from English into shoddy Swedish.

6. License

The More Fields Wordpress plugin is relased under GPL, and the following license can be found in the header of more-fields.php.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.You should have received a copy of the GNU General Public License along with this program. If not, see

86 Comments to “More Fields (pre WP 2.5)”

  1. Matt Says:

    This is great functionality. You should consider proposing it on Trac as a core patch.

  2. Hugo Says:

    Really good stuff, should be built into wordpress.

  3. Manne Says:

    Bra jobbat!

    Om man hade kunnat skapa separata skrivpaneler och inta bara få fler fält på de befintliga Skriv sida / Skriv inlägg-sidorna hade jag nog bytt från Custom Write Panel (http://wordpress.org/extend/plugins/custom-write-panel/) till denna..

  4. John Stevens Says:

    Brilliant! Thank you very much for your work!

    I have been looking for exactly this for some time and was trying to think of ways round the problem until I saw this today. I have not installed it yet, but with your excellent tutorial, I can see it is exactly what I was looking for.

    There can be no greater recommendation than that from Matt, above.

    From my point of view, it has meant I can stick with WordPress, rather than having to look at Drupal.

    Good luck and best wishes and many thanks once again for all your hard work.

  5. absolon Says:

    Great plugin. I downloaded and it’s 0.4 version but looks different then screeenshots provided here. Options > MoreFields is in green and partly in Swedish e.g. Inkludera pa Skriv/Redigera inlägg. Anyway it’s great.

  6. John Stevens Says:

    The only question I will ask is whether it is possible to style the resulting layout to look more like a conventional post.

    It would be nice to have the headings followed by a line break for example and the ability to put paragraphs in the text.

    I imagine this is impossible or too hard, so thanks anyway.

  7. sonika Says:

    Here a Russian translation for more fields v 0.4
    http://www.sonika.ru/blog/?dl=9
    Great plugin, thanks!

  8. tricky Says:

    This may sound like a silly question.. but is there any way so the box is collapsed by default? What should i change on the html for the panel output?

  9. Henrik Says:

    Thanks for your great feedback!

    John Stevens: I’ll include more formatting options in the next version.

    tricky: Sure. I’ll consider this as an option for version 0.5, should be easy to do. If you want to hack it, add the class ‘dbx-box-closed’ to the fieldset, i.e. it should read class=”dbx-box dbx-box-closed”.

    Sonika: Awesome!

  10. trm Says:

    It would be cool to preselect one entry of a drop-down-list. (Or to have a checkbox / radiobutton or s.th. )

  11. Peter Watts Says:

    Thanks so much for this. It served my purpose unbelievably well. Best of all, you put it up the day before I needed it. Any later and I may have tried doing it myself and that would have ended in disaster.

    Anyway, I have one question. Does anyone know how I could generate a list posts which have all had the same thing entered in a custom field. Using the employees examples above, I might want to show all posts where ’salesperson’ was entered in the position field. Essentially I want the custom field to act like a tag or category. It would great if I could integrate it into the native tagging or category system (so tag clouds and category lists would work nice) where anything entered into a particular field became a tag or category, but I can live without it.

    Any ideas?

    Cheers,

    Peter

  12. Henrik Says:

    Peter: There is some discussion on this over at the WordPress forums. I’ve suggested a solution to your problem there.

    trm: Yes, checkboxes and radiobuttons are coming.

    BTW, the functionality encapsulated in More FIelds is to be integrated into WordPress by version 2.6. Pretty nice, huh?

  13. Josh Says:

    Lovely plugin this is exactly what I have been looking for. One quick question: is there any way to re order the Write post page, so we can re shuffle the default stuff with our custom fields? I would really like to have some of my custom fields above the write post and others directly below.

    Cheers

    Josh

  14. Peter Watts Says:

    Good news on the Wordpress integration. You deserve it!

    As Josh says, I’d also love to be able arrange the write post page as I wished and save it. It is already possible to drag the boxes to where you want them, and it will remember the positions, however it is rather buggy and unreliable.

    One minor issue: When using drop down lists, the option you originally chose isn’t selected when you return to edit the post. The choice is still stored in the custom field, but it isn’t displayed in the drop-down list. This means you may not remember whether you chose something or not.

    Is this just happening for me?

    Cheers,

    Peter

  15. Tipunch Says:

    This plugin looks with interesting.
    Is there anyway one could automatically enter predefined standard data into the fields? like a default entry, which could be manually changed?
    Any ideas or suggestions welcome
    Thanks

    Martin

  16. Henrik Says:

    Josh & Peter: The admin interface changes in WordPress version 2.5 (since they’re skipping version 2.4), moving from two column to a single column - I’m hoping to implement an option for where the box appears for that version. As for now, the built in ‘memory’ is the best I can offer…

    Tipunch: There is not a way right now to set the default value of a field, apart from perhaps using JavaScript to insert the values on a document.onload. But it would be a great feature to have - I’ll think about how to best implement it into More Fields.

  17. jesse Says:

    Is there anyway to make a list where you can select more than one item? For example Im making a concert site and many band may play one night so I would have a title of Bands and then I would need to select multiple bands.

  18. Josh Says:

    Fantastic! This is exactly what I needed and I can’t wait to try it out.

    Question: in that wine example, if one wished to display the “Score” field using graphics (like 9 colored bottles of one followed by 1 gray bottle, to illustrate a score of 9), what might be the best way to do that?

  19. Henrik Says:

    jesse: No there is not support for that, but I’ll consider adding it.

    Josh: You could do something like this:

    <img src=”wine-score-<?php meta(’wine_score’); ?>.jpg”>

    where the images are wine-score-1.jpg, wine-score-2.jpg etc. The meta function is supplied in More Fields, for quick access to post metadata (i.e. Custom Fields).

  20. Josh Says:

    I thought it might be something like that; thank you. :)

  21. Peter Watts Says:

    I’m experiencing a strange problem. When I write a new post, none of the data entered in any of my ‘more fields’ is saved. However, when I edit an existing entry, it is saved perfectly. I’m not sure if this happened from the outset because most of my work has been with existing entries. I installed the plugin on a different blog and experienced the same problem.

    What is bizarre is that while the custom data isn’t saved with the post I just wrote, it appears in the custom fields section down the bottom when I go to write another new post. It is almost as if it has created a ‘blank’ entry and any custom data I enter on a new post is saved to the blank entry, not the one I just created. Does this make sense?

    It basically means I have to publish a post before I can add custom data.

    Do you know why this might be happening and how I can fix it?

    Cheers,

    Peter

  22. Henrik Says:

    Peter: Well spotted - I’ve updated to a new version held on WordPress.org (0.5), hoping to have solved this issue. Let me know if you still are having problems… Thanks for the beta-testing! :)

  23. Josh Says:

    I’m having a similar problem; data in More Fields text boxes is persistent from edit to edit, but data in dropdown menus isn’t. So if I edit a post, I have to go through all the dropdowns again. I’ll try the new version and see what happens.

    I really, really love this plugin, by the way.

  24. Peter Watts Says:

    On first glance, it would appear the new version has solved my two main problems. I’ll report back if I find anything else wrong. THANKS!!!!!

  25. Peter Watts Says:

    One more bug I forgot to mention: The write page does not display properly in IE. Personally I think everyone should just change to Firefox, but sadly not everyone is as enlightened.

    Any fields placed on the right display properly, however ones on the left do not. They all appear down the bottom, stacked on top of one another. It seems like a simple typo to me. I took a screenshot so you know what I mean:

    http://dopplerevolution.com/uploads/iebug.JPG

    Cheers,

    Peter

  26. Diego Says:

    Hi. Excellent plugin.
    I want to know how to hide the information, value or css data when the value of the field is empty.
    Hope someone can help me.
    Thanks!

  27. Josh Says:

    Well, I tried version .05 and it seems my problem remains: drop-down field entries are erased when I edit a post, so I have to go through them each time. Text Area fields are not affected by this.

  28. Matti Says:

    Tjena! Mycket bra jobbat!

    It’s the perfect plugin for my current purpose.
    However, I wondering whether there’s some kind of a filtering function.

    Let’s say I’ve got a key called “name”. On each of my pages this key is filled with a different name. Apart from that, I would like to have another page, that lists all the “name”-keys in an alphabetical manner.

    e.g:

    PAGE1:

    name=Paul

    PAGE2:

    name=Jack

    PAGE3:

    name=Bob

    Overview Page:

    name
    ——-
    Bob
    Jack
    Paul

    How can I get there?

    Thanks for suggestions!

  29. Henrik Says:

    Josh & Peter: Ok, thanks for reporting back, I’m gonna reveiew the code when I get an opportunity.

    Diego: When there is nothing stored in a Custom Field key, then the plugin should display nothing. What do you get instead?

    Matti: Hmm. Currently, I think that you’d have to resort to a direct database call. I do like the idea of filtering posts based on Custom Fields though.

  30. Nora Says:

    wow! great stuff… however, something strange is happening with my installation - it does not want to delete the boxes or fields… I’m using wp 2.3.2… do you have any idea how to solve this?

  31. Derek Says:

    How can you add the WYSIWYG editor to a text area? I need to be able to stylize the text.

  32. Nora Says:

    oh, no… now I’m getting the

    Fatal error: Cannot use string offset as an array in /home/teatar/public_html/wp/wp-content/plugins/more-fields/more-fields.php on line 374

    in the More Fields - Administration

    pleas help!!!

  33. Nora Says:

    my comment is not appearing so i’ll try once again:

    I’m getting the

    Fatal error: Cannot use string offset as an array in /home/teatar/public_html/wp/wp-content/plugins/more-fields/more-fields.php on line 374

    More Fields - Administration

  34. Henrik Says:

    Derek: More-fields does not supply this functionality. You can always resort to writing html code in the field directly, though.

    Nora: What version of PHP are you using?

  35. Nora Says:

    PHP version 5.2.4

  36. Nora Says:

    Another funny thing - since I installed this plugin my db changed the original collation to latin1_swedish_ci?!?!?

  37. Henrik Says:

    Nora: Wow, well, that truly is weird. Are you sure? The plugin does not perform any direct access to the databse (and not even via $wpdb), but only via the functions provided in WP (such as update_option and update_post_meta). Note that latin1_swedish_ci is the default collation for the latin1 character-set in MySql.

  38. Derek Says:

    I was able to add the editor to the textareas - I just edited the plugin and added the “mceEditor” class when the textarea is output.

  39. Matt Ronchetti Says:

    Is there any way to examine the return of meta() before displaying it? I’d like to display some code if the field has been completed but omit it if not. It seems I can’t compare the return to an empty string like in most cases.

  40. Peter Watts Says:

    Matt: I do it this way:

    At the top of my sidebar, I put each of the custom keys in a variable. Like so:

    ob_start();
    meta(’YOUR_KEY’);
    $YOUR_KEY = ob_get_contents();
    ob_end_clean();

    then later on I use a conditional tag, like so:

    this can also be adapted so something appears if any of a number of fields has been completed, like so:

    ob_start();
    meta(’link_1′) . meta(’link_2′) . meta(’link_3′) .
    $links = ob_get_contents();
    ob_end_clean();

    this means you can say if ($links) ie at least one is entered, output the heading LINKS, followed by the links if they exist.

    hope that made sense. there’s probably simpler ways, but hey, this works!

  41. Nora Says:

    Honestly - I have no idea what happened… but since all the data in the databases was lorem ipsum I just re-installed the wp and now everything is working just fine… even the collation is fine… still - one question… what do I have to do to display field titles when using

  42. Nora Says:

    um.. when using php do_action (’more_fields’, ‘nameofthe box’)

  43. Henrik Says:

    Derek: That is awesome, didn’t realize it was as easy as that! I’m going to add that for the version of this plugin that will go with WordPress 2.5.

    Matt: Yes there is, e.g.:

    $artist = get_meta(’artist’);

    I will add that to the documentation, since it’s there and available.

    Nora: If you do:

    $options = array(’format’ => ‘dl’);
    do_action (’more_fields’, ‘nameofthe box’, $options);

    That that will produce a dl/dt/dd list, which lists the field title in the dt tag, and the field value inside the dd tag.

  44. Nora Says:

    ok, now I’m really lost - where do I put this piece of code - inside the page I want to display it or the plug-in itself? sorry, I’m obviously trying to do more than I’m educated for

  45. Adam Says:

    Great plugin,

    Just wondering if it is possible to somehow have it add several different scores together. I have a review website where I have select fields to rate movies in 5 different categories, I want to show the overall score, basically add those field values together. Can that be done automatically somehow?

  46. berny Says:

    hi henrik!

    thanks for the nice plugin.

    just one suggestion: you use the prototype lib in the backend, but as you add the javascript call in the header, the prototype lib is loaded in the frontend as well. instead you could use the function wp_enqueue_script(’scriptName’); to add a script-adding hook. this would avoid doubled-script calls. moreover you could limit the overhead to the backend by using the filter add_action(’admin_menu’, ‘functionName’); instead of using the header. have a look on my plugins generalstats and timezonecalculator

    cheers
    berny

  47. Casey Says:

    omg… this will revolutionize WordPress! I’ve long used it for CMS sites and have had to struggle to figure out ways to use custom fields so that clients can understand and remember how to use them without me having to write a custom manual every time!

    awesome! I am SO glad to hear it will be part of the WP core soon.

  48. Henrik Melin Says:

    Nora:: That code would have to be included in your template.

    Adam: You can access individual custom fields (i.e. meta data) using the get_meta function, e.g.: $score = get_meta(’score1′) + get_meta(’score2′);

    berny: Thanks for your suggestions, I’m working on version 0.6 now and will make the changes you propose.

    Casey: Yeh, I’m pretty excited about the integration into the core too. Tha’ll save me having to support it ;)

  49. Casey Says:

    How does this code (from your example above)
    $options = array(’div’ => ‘employee_info’, ‘format’ => ‘dl’, ’show’ => array(’ci_name’, ‘ci_position’));
    do_action(’more_fields’, ‘Employee info’, $options);?>

    insert the h3 tag? I see the dl reference, but no h3?

    What if you want to have h2s around one key’s data but paragraphs around the next key’s data? I prefer to avoid adding html to my db whenever possible…

    is there some way to associate format with just one of the keys in the div?

    I’m experimenting, but would rather just know if you have time to answer… thanks!

  50. Henrik Melin Says:

    Casey: My mistake, the H3 is added when you supply a ‘format in the options, the value of which can be replaced with the, e.g. ‘title’ => ‘Employee Information’ option. If you want to do alot of customized displaying of your custom fields, I suggest that you access them directly using meta or get_meta in your templates. You shouldn’t have to store paragraph formatting of of the fields within the fields themselves.

    You are right in thinking that the template functions leaves a lot to be desired in terms of customizability. I’m gonna try to spec it out.

  51. Casey Says:

    Is there some way to:

    A) have multiple instances of a box of fields (for example, your employee information concept with name, bio, id# etc) on one page and return that data so you get Employee 1’s date followed by employee 2, etc, etc??

    or
    B) to have the more fields box for just one page, but then call that data (for many pages) to create a list on a “parent” page?

    for example, let’s say I have a main (parent) page “Employees” and a single sub (child) page for each employee… on the sub page, I use more fields to store data such as employee number, address, city, state, phone etc with the title being the employee’s name and the regular data field containing their general bio…

    Can I call that meta data from the main (parent) Employee page? For example, to create a list with the employee’s name, linked to their page (should be able to get this as $post->post_slug and post_title) with their phone number?

    In other words, is the meta data stored for each employee available in a way that I can call it from within a WordPress function like wp_list_pages()?

    Sorry to add so many questions, but I’m excited to use this plugin and need answers :)

  52. Adam Says:

    Thanks for the previous answer. My next question is kind of related. I want to be able to have a list in the sidebar that lists the top 5 movies according to the total score I have given to them, I know that wordpress can order them by date and name and so on, not sure about custom field values. Is there an easy way to have the top 5 movies according to total score shown somehow?

  53. Casey Says:

    What would cause errors such as:

    Warning: Missing argument 2 for p2m_meta_box_save() in /removed]/wp-content/plugins/more-fields/more-fields.php on line 554

    Warning: Cannot modify header information - headers already sent by (output started at /[removed]/wp-content/plugins/more-fields/more-fields.php:554) in /[removed]/wp-includes/pluggable.php on line 329

    I went into both files and there was an extra line after the closing ?> at the bottom (which wouldn’t have been there previously?) but this doesn’t fix the issue above. In my experience, the headers already sent error is often caused by extra spaces or lines before or after the opening/closing php tag

    I really want to incorporate this plugin into this site as it will definitely improve the ease of editing pages that make use of custom fields…

  54. Henrik Melin Says:

    Casey: You can display the content of Custom Fields within the loop (e.g. using the meta(’key’) function. The issue is selecting posts based on the values of Custom Fields - right now I suspect you have to do a custom MySql query. However, it’s on my list of features I’d like to add to this plugin.

    You could have a ‘employee’ category, which perform The Loop over, in which case it’s easy to select the posts you want to display.

    In regards to your error, I’m gonna have to have a look. I’m currently working on the 0.6 version, and preparing for the release ofd WP 2.5, which will introduce many changes to More Fields. Thanks for reporting - I do appreciate it.

    Adam: As stated previously in this comment, this is on my feature-request list, so I’m hoping to provide a easy and standard way of doing this. Right now, you probably have to do a custom MySql query…

  55. Casey Says:

    Thanks, Henrik! I did find that I could use the c2c_get_custom plugin to return any data provided by your plugin and since I am already familiar with that, the two together work brilliantly.

    Another major addition to your plugin that would rock my world would be to allow multiple entries in a box set of fields on a page… currently, you can only use the box to insert that set of data ONCE.

    Why is it not possible to have the box of fields available for a second insert? As it is now, when you go to the manage pages>specific page, the fields are populated with the previously-inserted data.

  56. Casey Says:

    BTW, Henrik, regarding the error messages… they occur on clicking the Save button after adding values to the box fields. However (if it helps to know), the data DOES get inserted, as it shows up later in the custom fields area.

  57. Henrik Melin Says:

    Casey: Do you want the same box to appear multiple times on each Write/Edit page? If so, this is not possible (as it is) since the keys have to be unique, i.e. you can not have a key called ‘artist’ appear twice - it will only save one ‘artist’ value.

    Don’t quite understand your second question - wouldn’t you want the field to be populated with the data you entered previously for the specific post?

    Thanks for the error details, I think I know what the problem is - will hopefully put out 0.6 this weekend. :)

  58. Casey Says:

    Hi, Henrik
    The error was related to the WordPress version, as it turns out. The server host was misreporting the version for some reason, but I managed to get it sorted out and all is working now. Thanks for looking.

    I am looking forward to 0.6!

    Meanwhile, what I was asking about relates to using a data set (which is how I think of your box of fields) more than once in a page. Going with your employees concept… the only way you can enter all employee data is to give each employee their own page (where you can enter the data)…

    but if you don’t plan to have individual employee pages, but want to have a single “overview” employee list, you can’t use more fields to enter data for each employee because it only allows one entry…
    if you hit the Save and continue editing button, the more fields data set is already populated. Entering any data into it just modifies the current set of fields rather than creating a new row of data.

    Custom fields don’t behave like that. You CAN have multiple instances of a key in one page. The “add new custom field” remains empty and any previous data shows up in the list of existing custom fields. I think that is how more fields should behave.

    And, the data entered into a more fields data set DOES show up in the existing custom fields anyway…. why repopulate the fields where you ENTER data? The data set should only be used to enter data, not to modify it. To modify such data, you can do it in the custom fields, using the update button.

    This would be a huge improvement, making more fields MORE FLEXIBLE… don’t you think? … unless it just is impossible to do it.

  59. Nora Says:

    Henrik, I’ve finally made this work, now I have another question… I have a box with several keys… I’m displaying both the title of each key and it’s value… however, sometimes there is no input data for some of the keys and in that case I would like to skip displaying the title… is there a way to pull this of?

  60. Henrik Melin Says:

    Casey: I disagree with you on how the plugin should work, and whilst what you describe could be useful for some, it is not what this plugin is trying to do.

    Nora: Shouldn’t do that so it’s probably a bug, I’ll have a look.

    BTW, 0.6 will be slightly delayed, got caught up in other stuff.

  61. James Says:

    This looks like it will do pretty much what I want. I’m looking to give my WP site a training log functionality. Seems like this much flexibility with custom fields and a bit of custom templating, along with separating out some categories, and seems like I’m good to go.

    One question, though. It may not be what you’d envisioned for this, but what about performing mathematical calculations on certain fields? For example, if I had distance fields, I’d like to be able to output total and average distance over a given time. As well, calculating amount of time spent in a certain heart rate range.

    I know it’s a little specific but I’m pretty sure this kind of capability would actually be used.

  62. Josh Says:

    Casey, why don’t you just use the employee’s name (staying with that example) as your key? So when you get a new employee, you make a new key with their name. Then it’s all on one page.

  63. James Says:

    This is a great piece of functionality. Hats off.

    However, there is a bug that I don’t think any of the prior comments mentioned.

    When I return all the custom fields from one of the boxes, when the data from key0 is displayed the title that’s returned isn’t that of title0 but the title of the box the data is in. In my case I have four boxes for my different triathlon training disciplines and the behaviour is the same for each of them.

    I can’t show you yet, because I’m still tweaking the display and writing some custom CSS. I can show it shortly if it’s not clear what I’m talking about.

  64. Siavash Says:

    It’s fantastic …
    please grow it up for adding codes automatically.
    thank you …

  65. Siavash Says:

    Excuse me 4 posting again … but I have a question :

    I have a table like this :


    and I want to display this table, when a box of my field is filled.
    please help me …
    thx again!

  66. Tobias Ross Says:

    How hard would it be to include a set of custom fields based on a page’s template? Like when you edit a page, and choose a template, different additional fields would be available depending on the page’s template.

    SInce this wouldn’t work with posts, perhaps a custom field that loads a given set of fields?

    The site I am working on has three specialized field sets, but it would be nice for them only to appear when needed…

    Thanks for a great plug-in!

  67. Peter Watts Says:

    Hello again. I am having trouble with More Fields clashing with another plugin called Fresh Posts. This plugin allows you to create ‘custom write panels’, however while More Fields is activated, these appear completely blank. It also occurs with the original ‘Custom Write Panels’ plugin that this plugin is based on. These plugins do similar things to More Fields, so it is not all that surprising that they are clashing. Do you know what the problem might be and how I can get around it?

    Don’t get me wrong, I’m an avid More Fields user, but this plugin offers some functionality (multiple write panels, default categorys, hiding standard panels) which more fields does not. It would be nice to be able to combine their abilities.

    Regards,

    Peter

  68. Nathan Rice Says:

    Is there any plan on upgrading this plugin for WordPress 2.5 when it is released? Also, will you keep the plugin backward compatible with previous versions?

    More info here:
    http://planetozh.com/blog/2008/02/wordpress-snippet-add_meta_box/
    and here:
    http://shuttlex.blogdns.net/2008/02/24/that-was-easy/

  69. ganzua Says:

    Great things happening here [hats off as someone said] but I am undereducated or have drunk too much of the wine i am including and/or missed a key line of “how to” that does not seem to be clear to me anywhere…

    I have the fields fileld in and appearing in my admin interfaces but cannot get the datos to appear on the page before the public

    (am i a fool or did I miss something : clearly yes I am not a programmer but I make wine if that helps!)

  70. Catherine Says:

    Hi —

    Love love LOVE the plugin, but a quick question — I have posted and published an entry with 4 custom fields. I need to add four more, so i add it into the plugin… when I add a new post, I can use all 8, but for previous posts only the original four fields will save, everything else will not. Is there a quick fix?

  71. Raydo Says:

    I found an error in the 0.5 plugin. There is a comment <!– /fieldset– !> that should be /fieldset –> . It was causing problems in IE ( but not FireFox ). I changed the comment and IE worked fine.

  72. Nora Says:

    Henrik, have you by any chance had the time to look in to my last question?

  73. Henrik Melin Says:

    James: You can get at the values of the custom fields using the get_meta() function. E.g. echo get_meta(’distance1′) + get_meta(’distance2′).

    Siavash: You’d have to use some conditionality: E.g.:

    <? if ($value = get_meta(’metaaa-key’)) : ?>
    <table>

    </table>
    <?php endif; ?>

    Tobias Ross: You could probably do it quite easy using JavaScript, by attaching a function to the template dropdown menu. I do quite like the idea of
    having different sets of boxes for different type content.

    Peter Watts: Hmmm, not sure why that is happening, I’m gonna have to install Fresh Posts to see what happens.

    Nathan Rice: Yes, I will be updating More Fields to work with 2.5.

    Ganzua: Try: <?php do_action(’more_fields’, ‘Geocaching’) ?> in your template.

    Catherine: Curious. Do they appear in the Custom Field section on the Write/Edit page? Are the keys you are using unique?

    Raydo: Thanks for catching that! Much appreciated.

    Nora:Yeh, and I’ve got a new version in the works, I’m just need to find some time to do some finishing touches. Apologies for the very slow release cycle…

  74. gofree Says:

    I have tried this plug-in, but seems not to work with WP 2.3.3

    I created:

    Name of Box: Tags
    Key0: tags | Tiltle0: Must Select | Type0: Select list

    [RS.com] Rapidshare.com, [RS.de] Rapidshare.de, [FF] Filefactory.com

    I did see it while writing the post, then I selected one of the option; but when I published the post, I couldn’t see where the Tags shows. How can I call this Tags function to appear in the post?

    Suggestion: It will be of more helpful if you can allow muti-selection from the dropdown by using control+click or sth.

    Thank you very much for the wonderful idea of this plug-in. And hope to see your new version soon.

    Regards,

  75. CircleReader Says:

    I don’t know how it compares to this one, but I’ve been looking at the Structured Blogging plugin to get a set of fields for using micorformats. Doing that as a custom field that loads other fields as Tobias suggests seems like a good idea (???).
    I also am using Fresh Post, and would, like Peter, enjoy having the functions of all these plugins if possible!

    Thanks for the plugin, Henrik, as well as the excellent instructions and support you’ve been offering above! :-)

  76. Richard Says:

    I installed “More Fields”
    I setup the fields, and i can see them on the admin side.
    But there is no content in the posting.
    What is wrong. I am a newbe.

    thanx, Richard

  77. Paolo Rossi Says:

    James is right: there’s a little bug. To fix it replace line 608,609 in more-fields.php with

    $caption = ($args[’title’]) ? ($args[’title’]) : $name;
    $html .= ” . $caption . ” . $nl;

    -paolo

  78. therealhg Says:

    I am also using WP 2.3.3, and I cannot get the meta(’key’) function to work inside a php if statement. The do_action() function works, but when I try to get the the value from just one field, no data is returned.

    I’ve created an if statement so that if the post is of a category with a specific parent category, it loads a template to show the data from the More Fields box. If I try to use the meta(’key’) function anywhere inside the if statement - even in the original post page and not in the template - no data is returned. If I use the meta() function outside the if statement, it works as described in your instructions.

    I’m also having the same problem as mentioned earlier with the values in my select fields not being saved when I go back to edit a post. The data is saved to the database, so this is probably a matter of fixing the “selected” parameter in the select values.

    Thanks for all your work in creating this great tool! I just wanted to share the issue I’m experiencing in case you had seen it before and knew an easy solution.

  79. James Says:

    Just checked back by chance to follow the discussion. Thanks for the catch, Paolo. The field label is fine now.

  80. James Says:

    Oh, and regarding the feedback Henrik, I realize it would be easy to add a few specific fields, but I’m more referring to an option in the admin that would allow you to do calculations on cumulative totals.

    For example, if you could choose a date range (monthly, weekly or yearly - even user-defined would be best), do averaging or addition, and then output, you’d really have something.

    There are absolutely no good fitness (running, triathlon, etc) log plugins for WP. What athletes are most looking for in their training logs are adding up time, distance, HR and then averaging them over a given period. Mind you, that would need to factor in types of data for certain fields, for example, different math for time vs. straight numbers.

    I know that’s way beyond the scope of what you’ve been thinking of with this, but I just wanted to clarify what I was getting at.

    Great plugin, BTW and very useful. You can see how I’ve output the workout data I track by looking at any of the posts in the following archive on my blog:

    http://james.wanless.info/topic/log/

  81. Jinsop lavayen Says:

    Hi from Ecuador.

    I´ve installed this plugin, but doesnt work.

    I´ve created specific fields, but they´re not show in the post… WHAT I HAVE TO DO?????

    Plz Help me.

    J. Lavayen

  82. Peter Watts Says:

    Hi Henrik,

    I understand you’re probably busy getting this working with 2.5, but in the meantime, do you think you could help me with something?

    I’m looking to hide some of the more fields input fields to certain users. In other words, I want to put a conditional statement somewhere that says if user-level > 4 { show input fields }

    I want low level users to be able to edit the post, but only to be able to see and edit some of the ‘more-fields’. However, when I go to edit the post, I want to be able to see everything.

    I get the feeling CSS hiding is the way to go, but I’m not sure if this would allow me to hide individual more fields entries or just all of them. Do you know if this would be possible and how I would do it?

    Much appreciated.

    Peter

  83. Peter Watts Says:

    I was having a look at the more-fields source code, and perhaps it could be done with a filter plugin (or similar). At about line 613 it has a section for deciding whether each box should be shown or not. If I could somehow insert a conditional that set the $show variable of the boxes i wanted to hide to ‘false’, it should work nicely. I’m just not sure how to phrase it. In layman terms I want:

    if box is (meta(’bad_box’)) {$show = false}

    This is as its going through the loop of all boxes. Do you know how I would ACTUALLY do it?

    Cheers,

    Peter

  84. noname Says:

    does not work with 2.5

  85. Michael Says:

    adds no values into the database on WP 2.5rc2

    how difficult it would be to add the “add media buttons” to an field, i would like to insert a file url from the new media lib into such a ‘more field’?

    (i’m seaching for an WP ninja for freelance jobs, i can pay/donate this development, write me an email and lets talk?)

  86. krembo99 Says:

    BTW..
    on the plugin page in wordpress it say :
    # Requires WordPress Version: 2.3.1 or higher
    # Compatible up to: 2.5
    so maybe it must be changed :-)

Leave a Reply