i’ve added a new feature to my site: custom post types. you can see the page here — as you can see, it’s all of my sketches i’ve done since last august
code
functions.php
first add this to allow for featured images (if it’s not already in there):
add_theme_support( 'post-thumbnails' );
This part will register the custom post type to wordpress
add_action( 'init', 'create_sketch' );
function create_sketch() {
$labels = array(
'name' => _x('Sketches', 'post type general name'),
'singular_name' => _x('Sketch', 'post type singular name'),
'add_new' => _x('Add New Sketch', 'Sweet'),
'add_new_item' => __('Add New Sketch'),
'edit_item' => __('Edit Sketch'),
'new_item' => __('New Sketch'),
'view_item' => __('View Sketch'),
'search_items' => __('Search Sketches'),
'not_found' => __('No Sketches found'),
'not_found_in_trash' => __('No Sketches found in Trash'),
'parent_item_colon' => ''
);
$supports = array('title', 'editor', 'revisions', 'thumbnail', 'comments');
register_post_type( 'sketches',
array(
'labels' => $labels,
'public' => true,
'supports' => $supports
)
);
}
Read more »