Hey there,
At the moment this is really buggy. I can only guess what your custom fields look like as you haven’t posted them up.
Here is something I’ve worked on just recently.
[accordion_fieldset]
type = fieldset_open
class=accordion
multiple = true
multipleButton = true
[accordion_title]
type = textfield
label = Accodion Title
class = text
blank = true
[accordion_introtext]
type = textfield
label = Teaser text for the Accordion
class = text
blank = true
[accordion_content]
type = textarea
hideKey = true
label = Content for the Accordion
blank = true
class = sharedescription
[accordion_fieldset]
type = fieldset_close
Make sure blank is set to true on your fields. You want the to occupy space in the database so everything lines up. Also the naming convention is ‘accordion_’. This is important because you’ll be using this to to do a like search from the database.
In your functions add this function I’ve written.
/**
* Constructs an ordered array from cf metadata
*
* @param string $like_item set in the CFT plugin based on the repeating fieldset name e.g. "test" would use 'test_fieldset'.
* Keep the meta_key unique.
* @return array associated array
*/
function get_cft_repeating_data( $like_item ){
global $post, $wpdb;
$sql = "SELECT * FROM $wpdb->postmeta WHERE post_id = $post->ID AND meta_key LIKE '%" . $like_item . "%' ORDER BY meta_id ASC";
$data_objects = $wpdb->get_results($sql);
$project = array();
$i = 0;
$fieldset = $like_item . '_fieldset';
foreach($data_objects as $data) {
// the name of the fieldset:
if ( $data->meta_key == $fieldset ) {
$limit = $data->meta_value;
}
$i = ( $i <= $limit ) ? $i : 1;
if( $data->meta_value != $limit && $data->meta_value !='' ) {
$project[$i]["$data->meta_key"] = $data->meta_value;
}
$i++;
}
if(!$limit && user_logged_in() )
echo 'Could not establish Custom Field Limit. The $like_item set was ' .$like_item . '<br /> SQL query was ' . $sql;
else
return $project;
}
In your template you can call your function with
$accordion_data = get_cft_repeating_data('accordion');
print_r($accordion_data);
And that should have your custom fields in order.
When I mention this is buggy I mean that I found while entering data into the Custom Field Template sometimes you’d push update and randomily custom fields would be lost. Quite frustrating.
The other thing is that I’ve experienced is that you can’t use TinyMCE on textareas. Although they show up, the ids are all the same when you duplicate them, so when editing the duplicated field only the first field would be affected.
Long rambling post. I hope this helps.