Created
January 5, 2019 03:25
-
-
Save wpsmithtwc/a2fceb957823f8c3bc60b65492c9bea6 to your computer and use it in GitHub Desktop.
WordPress: Rewrite Tutorial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'init', '\WPS\Plugins\Rewrite\PostTypeTaxonomy\register_cpt_resource' ); | |
/** | |
* Register the custom post type | |
* | |
* @since 1.2.0 | |
*/ | |
function register_cpt_resource() { | |
$labels = array( | |
'name' => __( 'Resources', 'wps' ), | |
'singular_name' => __( 'Resource', 'wps' ), | |
'add_new' => __( 'Add New', 'wps' ), | |
'add_new_item' => __( 'Add New Resource', 'wps' ), | |
'edit_item' => __( 'Edit Resource', 'wps' ), | |
'new_item' => __( 'New Resource', 'wps' ), | |
'view_item' => __( 'View Resource', 'wps' ), | |
'search_items' => __( 'Search Resources', 'wps' ), | |
'not_found' => __( 'No Resources found', 'wps' ), | |
'not_found_in_trash' => __( 'No Resources found in Trash', 'wps' ), | |
'parent_item_colon' => __( 'Parent Resource:', 'wps' ), | |
'menu_name' => __( 'Resources', 'wps' ), | |
); | |
$args = array( | |
'labels' => $labels, | |
'hierarchical' => true, | |
'supports' => array( 'title', 'editor', 'thumbnail', 'revisions', 'author', 'comments', 'discussion', 'page-attributes' ), | |
'public' => true, | |
'show_ui' => true, | |
'show_in_menu' => true, | |
'show_in_nav_menus' => true, | |
'publicly_queryable' => true, | |
'exclude_from_search' => false, | |
'has_archive' => true, | |
'query_var' => true, | |
'can_export' => true, | |
'rewrite' => array( 'slug' => 'resource', 'with_front' => false ), | |
'menu_icon' => 'dashicons-format-aside', | |
); | |
register_post_type( 'resource', $args ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment