WordPress.org

Ready to get started?Download WordPress

Forums

My custom_post_type fields are showing up in custom fields (4 posts)

  1. JohnnyN05
    Member
    Posted 3 years ago #

    Hi,

    I've created a 'custom post type' and when you go to add/edit a post or page, my 'custom post type' fields appear in the custom fields section. I don't want them there, is there a way to not display them in the custom fields section?

    Here are the arguments for my custom_post_type:

    $args = array(
    	'label'                => 'products',
    	'labels'               => array(),
    	'description'          => 'Displays Products',
    	'public'               => true,
    	'publicy_queryable'    => true,
    	'exclude_from_search'  => false,
    	'show_ui'              => '',
    	'capability_type'      => 'post',
    	'capabilities'         => array(),
    	'hierarchial'          => '',
    	'supports'             => array(),
    	'register_meta_box_cb' => '',
    	'taxonomies'           => array( 'category', 'post_tag' ),
    	'menu_position'        => 4,
    	'menu_icon'            => '',
    	'permalink_epmask'     => '',
    	'rewrite'              => '',
    	'query_var'            => '',
    	'can_export'           => true,
    	'show_in_nav_menus'    => true,
    	'_builtin'             => '',
    	'_edit_link'           => ''
    );
    
    $labels = array(
    	'name'               => 'Products',
    	'singular_name'      => 'Product',
    	'add_new'            => 'Add New',
    	'add_new_item'       => 'Add New Product',
    	'edit_item'          => 'Edit Product',
    	'new_item'           => 'New Product',
    	'view_item'          => 'View Product',
    	'search_items'       => 'Search Products',
    	'not_found'          => 'Products not found',
    	'not_found_in_trash' => 'Products not found in trash',
    	'parent_item_colon'  => ''
    );
    
    // hook
    register_post_type('product', $args);

    Thanks!

  2. easilyamused
    Member
    Posted 3 years ago #

    Any luck with this?

    I'm having a similar problem. Any luck fixing this?

    I added a meta_box to my custom post type and name showing up in the rest of the post and pages in the custom fields.

    Any feed back would be helpful.

    Thanks,
    -James Tryon

  3. JohnnyN05
    Member
    Posted 3 years ago #

    Hey James,

    Actually, I've put all my custom_post_type fields in an array and just called it (for the sake of the example above) products_data. I've re-wrote my code to unserialize and extract the array. It still shows up in the Custom Fields area though, but at least its just one field and not a whole bunch.

    Thanks!

  4. Rev. Voodoo
    Volunteer Moderator
    Posted 3 years ago #

    @easilyamused, how did you add the meta box?

    I decided to forego the register_meta_box_cb in registering my CPTs and instead just made a function for my meta boxes

    add_meta_box('ve_social_links', 'Social Links', 've_social_links', 've_members', 'side', 'default');

    in there adds a meta box to only ve_members CPT
    http://wordpress.pastebin.com/K6MKGQ2B
    if you are interested in the full code

    It adds a set of meta boxes to ve_members CPT, then another box to standard posts

Topic Closed

This topic has been closed to new replies.

About this Topic