Skip to content

Instantly share code, notes, and snippets.

@waviaei
Last active December 12, 2015 09:58
Show Gist options
  • Select an option

  • Save waviaei/4755111 to your computer and use it in GitHub Desktop.

Select an option

Save waviaei/4755111 to your computer and use it in GitHub Desktop.
function my_post_types() {
// Set labels
$labels = array(
'name' => 'Questions',
'singular_name' => 'Question',
'add_new' => 'Add New Question',
'add_new_item' => 'Add New Question',
'edit_item' => 'Edit Question',
'new_item' => 'New Question',
'all_items' => 'All Questions',
'view_item' => 'View Question',
'search_items' => 'Search Questions',
'not_found' => 'No questions found',
'not_found_in_trash' => 'No questions found in Trash',
'parent_item_colon' => '',
'menu_name' => 'Questions'
);
// Set arguments
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'question' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null
);
register_post_type( 'my_post_types', $args );
}
// Always add to init
add_action( 'init', 'my_post_types' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment