Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Replicate Field Set [add new] WordPress

  • SOLVED

I've written a custom post type.

I have a metabox with several 3 fields in it. Once the user adds the info the fields, I want to have a button which will allow them to post the information, but then present them with a set of the same blank fields.

I know this can be done but not sure how.

Also, I need to know how to use save the information and how to callback the information in a template. Not sure how to do the call back since the new fields would be dynamic.

Please help!

function mcms_testimonials() {
global $post;
$custom = get_post_custom($post->ID);
$mcms_testimonial_name = $custom["mcms_testimonial_name"][0];
$mcms_testimonial_the = $custom["mcms_testimonial_the"][0];
$mcms_testimonial_audio = $custom["mcms_testimonial_audio"][0];
?>
<div class="mcms_optinpage">
<div id='testimonial' style="border:1px solid #ccc;padding:10px;border-radius:2px;">
<table>
<label>Testimonial Name</label><div class='description'>Enter the name of your testimonial.</div>
<input type='text' style='width: 100% id='mcms_testimonial_name' name='mcms_testimonial_name' value='<?php echo $mcms_testimonial_name ?>' size='50'/>
<label>The Testimonial</label><div class='description'>Enter the testimonial which your prospect gave you.</div>
<div id='editorcontainer' style='margin-bottom: 20px;' ><textarea rows='3' cols='20' style='width: 100% !important; margin-bottom: 25px;' id='mcms_testimonial_the' name='mcms_testimonial_the' class='theEditor'><?php echo $mcms_testimonial_the ?></textarea></div>
<label>OPTIONIAL Testimonial Audio Button</label><div class='description'>Enter the URL to the mp3 of your testimonial.</div>
<input type='text' style='width: 100% id='mcms_testimonial_audio' name='mcms_testimonial_audio' value='<?php echo $mcms_testimonial_audio ?>' size='50'/>
</table>
</div>
</div>
<?php
}

Answers (4)

2011-08-18

Christianto answers:

Could you post your metabox code..?


Armand Morin comments:

just posted code.


Christianto comments:

Hi,

I'm create the code and test it on my localhost, I attach a screenshot.

When user enter the value on the field and press "add testimonial" the value will be save in database, a box will be added, and the form field will be emptied. The testimonial box added can be delete. All will be run in background without page refresh..

is this meet your requirement?

Also could you post your css/style for this metabox?
it only need the style to make it look better.. :D

Since you use tinyMCE on your metabox its get little hard, so I don't mind if you increase the prize lil'bit.. :D