Skip to content

Instantly share code, notes, and snippets.

@Galibri
Last active October 2, 2019 18:14
Show Gist options
  • Save Galibri/456cf17016fe569c3c58109ac47141f8 to your computer and use it in GitHub Desktop.
Save Galibri/456cf17016fe569c3c58109ac47141f8 to your computer and use it in GitHub Desktop.
Register Custom Post Type (Repo)
<?php
add_action( 'init', 'bs_create_github_post_type' );
/**
* Register a repo post type.
*
* @link http://codex.wordpress.org/Function_Reference/register_post_type
*/
function bs_create_github_post_type() {
$labels = array(
'name' => __( 'Repos', 'text-domain' ),
'singular_name' => __( 'Repo', 'text-domain' ),
'menu_name' => __( 'Repos', 'text-domain' ),
'name_admin_bar' => __( 'Repo', 'text-domain' ),
'add_new' => __( 'Add New', 'repo', 'text-domain' ),
'add_new_item' => __( 'Add New Repo', 'text-domain' ),
'new_item' => __( 'New Repo', 'text-domain' ),
'edit_item' => __( 'Edit Repo', 'text-domain' ),
'view_item' => __( 'View Repo', 'text-domain' ),
'all_items' => __( 'All Repos', 'text-domain' ),
'search_items' => __( 'Search Repos', 'text-domain' ),
'parent_item_colon' => __( 'Parent Repos:', 'text-domain' ),
'not_found' => __( 'No repos found.', 'text-domain' ),
'not_found_in_trash' => __( 'No repos found in Trash.', 'text-domain' )
);
$args = array(
'labels' => $labels,
'description' => __( 'Description.', 'text-domain' ),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'repo' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'editor' )
);
register_post_type( 'repo', $args );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment