Support » Plugins » Custom Post Type– one custom field works, but I'm looking for two

  • I have a custom post type called “Digest,” for which I want three fields: the title, a custom “digest name”, and a custom “digest details.” I can get the title and the digest name to save every time, but the digest details are always empty whenever I save. What should I do to make the digest details save as well? Thanks in advance!

    Here’s the applicable part of my function file (I edited it from something I found on a blog, but I can’t seem to find that again).

    add_action('init', 'create_digest');
    function create_digest() {
    $digest_args = array(
    'label' => __('Digests'),
    'singular_label' => __('Digest'),
    'public' => true,
    'show_ui' => true,
    'capability_type' => 'post',
    'hierarchical' => false,
    'rewrite' => true,
    'supports' => array('title',)
    add_action("admin_init", "add_digest");
    add_action('save_post', 'update_digest');
    function add_digest(){
    add_meta_box("digest_options", "Digest Options", "digest_options", "digest", "normal", "low");
    function digest_options(){
    global $post;
    $custom = get_post_custom($post->ID);
    $digest_name = $custom["digest_name"][0];
    $digest_details = $custom["digest_details"][1];
    <div id="digest-options">
    <label>Digest Name:</label><input name="digest_name" value="<?php echo $digest_name; ?>" />
    <label>Digest Details:</label><input name="digest_details" value="<?php echo $digest_details; ?>" />
    function update_digest(){
    global $post;
    update_post_meta($post->ID, "digest_name", $_POST["digest_name"]);
    update_post_meta($post->ID, "digest_details", $_POST["digest_details"]);
    add_filter("manage_edit-digest_columns", "digest_edit_columns");
    add_action("manage_posts_custom_column", "digest_columns_display");
    function digest_edit_columns($digest_columns){
    $digest_columns = array(
    "cb" => "<input type=\"checkbox\" />",
    "title" => "Project Title",
    "description" => "Description",
    return $digest_columns;
    function digest_columns_display($digest_columns){
    switch ($digest_columns)
    case "description":

  • The topic ‘Custom Post Type– one custom field works, but I'm looking for two’ is closed to new replies.