Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Punal Chotrani
8,817 PointsData not saving in a newly created custom fields in a custom post.
I have created a new custom post type "skills", and added some fields to it.
- Fields 1: a normal text metabox
- Field 2: a Radio buttons, which when selected should display on the frontend.
I have 2 issues. Both the data is not saving, when i hit update, and when it updates i need to save it on the front-end.
Below is the code.
function true_add_a_metabox() {
add_meta_box(
'true_metabox',
'Skill Level Percentage',
'true_display_metabox',
'skills',
'normal',
'high'
);
}
add_action( 'admin_menu', 'true_add_a_metabox' );
function true_display_metabox($post) {
wp_nonce_field( basename( __FILE__ ), 'true_metabox_nonce' );
$html .= '<p><label>Enter Skill % <input type="text" name="seotitle" value="' . get_post_meta($post->ID, 'true_title',true) . '" /></label></p>';
$html .= '<p><label><input type="radio" name="noindex"';
$html .= (get_post_meta($post->ID, 'true_noindex',true) == 'on') ? ' checked="checked"' : '';
$html .= ' /> Expert</label></p>';
$html .= '<p><label><input type="radio" name="noindex"';
$html .= (get_post_meta($post->ID, 'true_noindex',true) == 'on') ? ' checked="checked"' : '';
$html .= ' /> Proficient</label></p>';
$html .= '<p><label><input type="radio" name="noindex"';
$html .= (get_post_meta($post->ID, 'true_noindex',true) == 'on') ? ' checked="checked"' : '';
$html .= ' /> Basic</label></p>';
$html .= '<p><label><input type="radio" name="noindex"';
$html .= (get_post_meta($post->ID, 'true_noindex',true) == 'on') ? ' checked="checked"' : '';
$html .= ' /> Learning</label></p>';
/*
* print all of this
*/
echo $html;
}
Any help with this would be great.
Thanks
2 Answers

Chris Shaw
26,650 PointsHi Punal,
Have a read through the following article as you're missing the save functionality for your custom fields as WordPress doesn't handle this automatically for us.

Punal Chotrani
8,817 PointsHi Chris,
I thought as much, i had to do a save function.
Thanks for your help, great link.

Chris Shaw
26,650 PointsNo worries, glad you got it sorted.