I’ve registered a custom post type, ensured that ‘supports’ has ‘comments’, and comments are allowed on new posts under settings -> discussion.
I do see the check boxes for allow comments and allow trackbacks/pings. If I check ‘allow comments’, then update/publish post, it automatically gets unchecked.
I have no clue why. The only solution I’ve found is through a SQL query. I can add an action to run a query after save, but I’d like to know what is the problem.
register_post_type( 'ott_products',
array(
'labels' => array(
'name' => __( 'OhTheThings Products' ),
'singular_name' => __( 'OhTheThings Product' ),
'add_new' => __( 'Add New' ),
'add_new_item' => __( 'Add New Product Listing' ),
'edit' => __( 'Edit' ),
'edit_item' => __( 'Edit Product Listing' ),
'new_item' => __( 'New Product Listing' ),
'view' => __( 'View Product' ),
'view_item' => __( 'View Product' ),
'search_items' => __( 'Search Products' ),
'not_found' => __( 'No product found' ),
'not_found_in_trash' => __( 'No product found in Trash' ),
'parent' => __( 'Parent Product' )
),
'public' => true, // Can be seen/edited by public.
'menu_position' => 5, //Position, in this case, just after post.
'supports' => array( 'comments', 'title', 'editor', 'thumbnail' ),
'taxonomies' => array( 'category' ),
'rewrite' => array( 'slug' => 'product' ),
)
);
Here’s the code for my post type, but I don’t really think it’s relevant.
EDIT: Code which is making and saving custom fields…
function display_product_info_meta_box($post) {
wp_nonce_field( plugin_basename( __FILE__ ), 'ott_checknonce' );
$price = get_post_meta($post->ID, 'price', true);
$viaTitle = get_post_meta($post->ID, 'viaTitle', true);
$viaLink = get_post_meta($post->ID, 'viaLink', true);
$learnmore = get_post_meta($post->ID, 'learnmore', true);
$description = get_post_meta($post->ID, 'description', true);
$userreview = get_post_meta($post->ID, 'userreview', true);
$colorscheme = get_post_meta($post->ID, 'colorscheme', true);
echo '<table class="form-table">
<tr>
<th><label for="colorscheme">Color Scheme</label></th>
<td>
<input type="text" name="colorscheme" id="colorscheme" value="'.$colorscheme.'" size="30" />
<br /><span class="description">Accepted values: green, red, blue, corresponding to geeky, home life, and oh wow respectively.<br>Default value is green, ie, geeky.</span>
</td>
</tr>
<tr>
<th><label for="price">Price (USD)</label></th>
<td>
<input type="text" name="price" id="price" value="'.$price.'" size="30" />
<br /><span class="description">The price, in USD</span>
</td>
</tr>
<tr>
<th><label for="viaTitle">Via (Title)</label></th>
<td>
<input type="text" name="viaTitle" id="viaTitle" value="'.$viaTitle.'" size="30" />
<br /><span class="description">Example: \'Amazon\' will output \'Via Amazon\'</span>
</td>
</tr>
<tr>
<th><label for="viaLink">Via (Link)</label></th>
<td>
<input type="text" name="viaLink" id="viaLink" value="'.$viaLink.'" size="30" />
<br /><span class="description">The link to go in the \'via\'</span>
</td>
</tr>
<tr>
<th><label for="learnmore">Learn More URL</label></th>
<td>
<input type="text" name="learnmore" id="learnmore" value="'.$learnmore.'" size="30" />
<br /><span class="description">The url the \'Learn More\' button should lead to.</span>
</td>
</tr>
<tr>
<th><label for="description">Poem/Description</label></th>
<td>
<textarea name="description" id="description" cols="60" rows="15">'.$description.'</textarea>
<br /><span class="description">The poem/description. Try and keep it short :)</span>
</td>
</tr>
<tr>
<th><label for="userreview">Featured User Review/Product Features</label></th>
<td>
<textarea name="userreview" id="userreview" cols="60" rows="15">'.$userreview.'</textarea>
<br /><span class="description">The \'Featured User Review/Product features\' field. Please prepend with \'<h1>Featured User Review</h1>: \' if it\'s a user review</span>
</td>
</tr>
</table>'; // end table
};
function ottycb_save_postdata($post_id) {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return;
if ( !wp_verify_nonce( $_POST['ott_checknonce'], plugin_basename( __FILE__ ) ) )
return;
update_post_meta($post_id, "price", $_POST["price"]);
update_post_meta($post_id, "viaTitle", $_POST["viaTitle"]);
update_post_meta($post_id, "viaLink", $_POST["viaLink"]);
update_post_meta($post_id, "learnmore", $_POST["learnmore"]);
update_post_meta($post_id, "description", $_POST["description"]);
update_post_meta($post_id, "userreview", $_POST["userreview"]);
update_post_meta($post_id, "colorscheme", $_POST["colorscheme"]);
};