Skip to content

Instantly share code, notes, and snippets.

@robbiegod
Forked from dom082186/register-post-type.php
Created October 4, 2017 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robbiegod/97de76a7b47fedd520bf3ccdbd0d6127 to your computer and use it in GitHub Desktop.
Save robbiegod/97de76a7b47fedd520bf3ccdbd0d6127 to your computer and use it in GitHub Desktop.
Register Post Type
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class Skubbs_Post_Types {
public static function init() {
add_action( 'init', array( __CLASS__, 'register_post_types' ), 5 );
}
public static function register_post_types() {
register_post_type( 'bike_shops',
array(
'labels' => array(
'name' => 'Bike Shops',
'singular_name' => 'Bike Shop',
'menu_name' => 'Bike Shops',
'add_new' => 'Add Bike Shop',
'add_new_item' => 'Add New Bike Shop',
'edit' => 'Edit',
'new_item' => 'New Bike Shop',
'view' => 'View Bike Shop',
'search_item' => 'Search Bike Shops',
'not_found' => 'No Bike Shops found',
'not_found_in_trash' => 'No Bike Shops found in trash',
'parent' => 'Parent Bike Shop'
),
register_taxonomy( 'bike_shops_cat', 'bike_shops',
array(
'hierarchical' => true,
'label' => 'Category',
'rewrite' => array( 'slug' => 'bike_shops_cat' ),
'query_var' => true
)
),
'description' => 'This is where you can add new Bike Shops.',
'public' => true,
'show_ui' => true,
'capability_type' => 'page',
'publicly_queryable' => true,
'hierarchical' => false,
'rewrite' => array( 'slug' => 'bike_shops' ),
'query_var' => true,
'supports' => array( 'title' ),
'has_archive' => true,
'show_in_nav_menus' => true
)
);
}
}
Skubbs_Post_Types::init();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment