Skip to content

Instantly share code, notes, and snippets.

@wpsmithtwc
Created January 5, 2019 03:25
Show Gist options
  • Save wpsmithtwc/a2fceb957823f8c3bc60b65492c9bea6 to your computer and use it in GitHub Desktop.
Save wpsmithtwc/a2fceb957823f8c3bc60b65492c9bea6 to your computer and use it in GitHub Desktop.

Revisions

  1. wpsmithtwc created this gist Jan 5, 2019.
    41 changes: 41 additions & 0 deletions resource-post-type.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    <?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 );
    }