• Hello,

    I have custom post types set up and running and now need to add custom fields which the single.php template will then pull into place.

    There are tutorials for this but I can’t get any of them to work and wondered if someone could look at the code I’m using to create the custom post type in functions.php to see if there is a problem, or point out what I’m doing wrong.

    The code is as follows:

    add_action('init', 'books_register');
    
    function books_register() {
    
    	$labels = array(
    		'name' => _x('Books', 'post type general name'),
    		'singular_name' => _x('Book', 'post type singular name'),
    		'add_new' => _x('Add New', 'portfolio item'),
    		'add_new_item' => __('Add New Book'),
    		'edit_item' => __('Edit Book'),
    		'new_item' => __('New Book'),
    		'view_item' => __('View Book'),
    		'search_items' => __('Search Books'),
    		'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' => true,
    		'capability_type' => 'post',
    		'hierarchical' => false,
    		'menu_position' => 5,
    		'supports' => array('title','thumbnail','revisions'),
    		'taxonomies' => array('category', 'post_tag')
    	  ); 
    
    	register_post_type( 'book' , $args );
    
    }

    The site will list books and so I need to add quite a few custom fields, for binding information, reviews, author info etc etc.

    All help appreciated!

  • The topic ‘Adding Custom Post/Meta Fields on Custom Post Types’ is closed to new replies.