• I’ve created a custom post type “products” with some fields(price, image1, image2, etc).
    I create products and all works fine but when i try to create a new PAGE, the page creation form shows some custom fields from the product custom type(price, image1, image2, etc).

    Why? I don’t want to show that fields in the page form.
    Must i declare something for showing that fields only in the products form?
    In my functions.php i wrote:

    $labels = array(
    		'name' => _x('Products', 'post type general name'),
    		'singular_name' => _x('Product', 'post type singular name'),
    		'add_new' => _x('Add New', 'product item'),
    		'add_new_item' => __('Add New product'),
    		'edit_item' => __('Edit product'),
    		'new_item' => __('New product'),
    		'view_item' => __('View product'),
    		'search_items' => __('Search product'),
    		'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,
    		//'menu_icon' => get_stylesheet_directory_uri() . '/menu_icon.png',
    		'rewrite' => true,
    		'capability_type' => 'post',
    		'hierarchical' => false,
    		'menu_position' => null,
    		'supports' => array('title','editor','thumbnail')
    	  ); 
    
    	register_post_type( 'product' , $args );

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter oterox

    (@oterox)

    The code for the custom fields:

    add_action("admin_init", "km_admin_boxes_init");
    
    function km_admin_boxes_init(){
      add_meta_box("km_product_meta", "Product data", "km_product_meta", "product", "normal", "low");
    }
    
    function km_product_meta() {
      global $post;
      $custom = get_post_custom($post->ID);
      $kmprice = $custom["kmprice"][0];
    
      ?>
      <p><label>Price:</label><br />
      <input name="kmprice" value="<?php echo $kmprice; ?>" />

    I’m experiencing the same problem, but haven’t seen any solution yet. Have you had any luck?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom post type fields showing in page form¿?’ is closed to new replies.