Skip to content

Instantly share code, notes, and snippets.

@jackperry
Created February 9, 2012 17:51
Show Gist options
  • Save jackperry/1781556 to your computer and use it in GitHub Desktop.
Save jackperry/1781556 to your computer and use it in GitHub Desktop.
Sarah Winnem CPT
Want my newsroom to be url.com/newsroom (currently throws a 404)
Posts should be url.com/newsroom/post-title (currently works)
Code in functions.php:
// newsroom custom content type
function bment_post_type_newsroom() {
register_post_type(
'newsroom', array(
'labels' => array(
'name' => __( 'Newsroom' ),
'singular_name' => __( 'News Article' ),
'add_new' => __( 'Add New' ),
'add_new_item' => __( 'Add New News Article' ),
'edit' => __( 'Edit' ),
'edit_item' => __( 'Edit News Article' ),
'new_item' => __( 'New News Article' ),
'view' => __( 'View News Article' ),
'view_item' => __( 'View News Article' ),
'search_items' => __( 'Search News Articles' ),
'not_found' => __( 'No news articles found' ),
'not_found_in_trash' => __( 'No news articles found in Trash' ),
'parent' => __( 'Newsroom' ),
),
'public' => true,
'show_ui' => true,
'menu_position' => 20,
'hierarchical' => true,
'supports' => array(
'title',
'editor',
'excerpt',
'custom-fields',
'thumbnail',
'page-attributes'
),
'rewrite' => array(
'slug' => 'newsroom',
'with_front' => false
),
'has_archive' => 'newsroom'
));
register_taxonomy_for_object_type('post_tag', 'Newsroom');
}
add_action('init', 'bment_post_type_newsroom');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment