0

Am attempting to create a custom post type and have it contain very specific info. Name, address, city, state, zip and photo - as a post. Need to have the admin section show form fields named as what these items are. Yes, I could use custom fields, however want to do it right and setup form input boxes (or meta boxes) for each specific piece of data.

Having the post creation dialog have a specific file upload input for the photo would be pretty smooth.

Will use plugins if necessary, however would rather code it in, as it is very specific (and should stay that way).

Looking for suggestions or tutorials that would cover this specific need, or plugins that anyone has used that do this.

1

Hi What you need to do is add some code to your functions.php file within your theme..

ie: register_post_type()

this will generate a new area under the likes of media on your admin menu.. the way you set this up, will depend on what is enabled and visible on the post write/edit pages..

for instance this is a copy paste from a theme file i have, this generates a new video post type,

add_action( 'init', 'register_videos_post_type' );

function register_videos_post_type() {
    register_post_type( 'videos',
        array(
            'labels' => array(
                'name' => __( 'Videos' ),
                'singular_name' => __( 'Video' ),
                'add_new' => __( 'Add New' ),
                'add_new_item' => __( 'Add New Video' ),
                'edit' => __( 'Edit' ),
                'edit_item' => __( 'Edit Video' ),
                'new_item' => __( 'New Video' ),
                'view' => __( 'View Video' ),
                'view_item' => __( 'View Video' ),
                'search_items' => __( 'Search Videos' ),
                'not_found' => __( 'No videos found' ),
                'not_found_in_trash' => __( 'No videos found in Trash' ),
                'parent' => __( 'Parent Video' ),
            ),
            'public' => true,
            'show_ui' => true,
            'publicly_queryable' => true,
            'show_in_nav_menus' => false,
            'exclude_from_search' => false,
            'hierarchical' => false,
            'rewrite' => array('slug'=>'video'),
            'supports' => array('title', 'editor', 'excerpt', 'thumbnail', 'comments', 'author'),
            'taxonomies' => array('post_tag')
        )
    );
flush_rewrite_rules();
}

this will enable a whole new video post type, which supports:

array('title', 'editor', 'excerpt', 'thumbnail', 'comments', 'author'),

have a read through the register_post_type()

hope this helps..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy