I am creating a custom content type and on the add new page and edit page the editor is currently showing up when I have it coded not to be there. This was working fine about a week ago and I’m unsure what went wrong. Any ideas?
Here is the code from my functions page:
add_action('init', 'recipe_register');
function recipe_register() {
$labels = array(
'name' => _x('Recipes', 'post type general recipe'),
'singular_name' => _x('Person', 'post type singular name'),
'add_new' => _x('Add New Recipe', 'recipe'),
'add_new_recipe' => __('Add New Recipe'),
'edit_recipe' => __('Edit Recipe'),
'new_recipe' => __('New Recipe'),
'view_recipe' => __('View Recipe'),
'search_recipes' => __('Search Recipes'),
'not_found' => __('Nothing found'),
'not_found_in_trash' => __('Nothing found in Trash'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => array("slug" => "recipes"),
'capability_type' => 'post',
'hierarchical' => true,
'menu_position' => null,
'supports' => array('title','author','thumbnail')
);
register_post_type('recipe',$args);
register_taxonomy('type','recipe',array(
'hierarchical' => true,
'label' => 'Type',
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'type' ),
));
}
add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'recipe',
array(
'labels' => array(
'name' => __( 'Recipe' ),
'singular_name' => __( 'Recipe' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'recipe')
)
);
}
add_action("admin_init", "admin_init");
function admin_init(){
add_meta_box("recipedetails_meta", "Recipe Information", "recipe_meta", "recipe", "normal", "low");
}
function recipe_meta() {
global $post;
$custom = get_post_custom($post->ID);
$name = $custom["recipe_name"][0];
$yield = $custom["recipe_yield"][0];
$time = $custom["recipe_time"][0];
$ingredients = $custom["recipe_ingredients"][0];
$directions = $custom["recipe_directions"][0];
$calories = $custom["recipe_calories"][0];
$done = $custom["recipe_done"][0];
$original = $custom["recipe_original"][0];
?>
<div id='peoplemanager_form_container'>
<div id='shortanswers'>
<p><label>Name</label><br /><input name="recipe_name" value="<?php echo $name; ?>"></p>
<p><label>Yield</label><br /><input name="recipe_yield" value="<?php echo $yield; ?>"></p>
<p><label>Time</label><br /><input name="recipe_time" value="<?php echo $time; ?>"></p>
<p><label>Calories</label><br /><input name="recipe_calories" value="<?php echo $calories; ?>"></p>
<p><label>URL</label><br /><input name="recipe_fat" value="<?php echo $done; ?>"></p>
<p><label>Original</label><br /><input name="recipe_original" value="<?php echo $original; ?>"></p>
<p><label>Ingredients:</label><br />
<textarea cols="50" rows="5" name="recipe_ingredients"><?php echo $ingredients; ?></textarea></p>
<p><label>Directions:</label><br />
<textarea cols="50" rows="5" name="recipe_directions"><?php echo $directions; ?></textarea></p>
</div>
</div>
<?php
}
add_action('save_post', 'save_details');
function save_details(){
global $post;
update_post_meta($post->ID, "recipe_name", $_POST["recipe_name"]);
update_post_meta($post->ID, "recipe_yield", $_POST["recipe_yield"]);
update_post_meta($post->ID, "recipe_time", $_POST["recipe_time"]);
update_post_meta($post->ID, "recipe_ingredients", $_POST["recipe_ingredients"]);
update_post_meta($post->ID, "recipe_directions", $_POST["recipe_directions"]);
update_post_meta($post->ID, "recipe_calories", $_POST["recipe_calories"]);
update_post_meta($post->ID, "recipe_done", $_POST["recipe_done"]);
}
add_filter('manage_edit-recipe_columns', 'add_recipe_columns');
function add_recipe_columns($gallery_columns) {
$new_columns['cb'] = '<input type="checkbox" />';
$new_columns['title'] = _x('Recipe', 'column name');
$new_columns['calories'] = __('Calories');
$new_columns['time'] = __('Time');
$new_columns['type'] = __('Type');
return $new_columns;
}
add_action('manage_recipe_posts_custom_column', 'manage_recipe_columns', 10, 2);
function manage_recipe_columns($column_name, $id) {
global $post;
switch ($column_name) {
case 'calories':
echo get_post_meta( $post->ID , 'recipe_calories' , true );
break;
case 'time':
echo get_post_meta( $post->ID, 'recipe_time' , true );
break;
case 'type':
echo get_the_term_list($post->ID, 'type', '', ', ','');
break;
default:
break;
}
}
?>
you are getting the the editor because of the function *create_post_type()* in your code that you have shown above, it is duplicating the function *recipe_register()*. Just remove the *create_post_type* and every thing should be fine.