kriskhoury
11/20/2019 - 4:39 PM

WP Add Custom Post Type

add_action( 'init', '_add_resources' );
function _add_resources() {
    $labels = array(
      'name' => _x('Resources', 'post type general name'),
      'singular_name' => _x('Resource', 'post type singular name'),
      'add_new' => _x('Add New', 'Resource item'),
      'add_new_item' => __('Add New Resource Item'),
      'edit_item' => __('Edit Resource Item'),
      'new_item' => __('New Resource Item'),
      'view_item' => __('View Resource Item'),
      'search_items' => __('Search Resource'),
      'not_found' =>  __('Nothing found'),
      'not_found_in_trash' => __('Nothing found in Trash'),
      'parent_item_colon' => ''
    );
    $args = array(
      'labels'              => $labels,
      'menu_icon'           => 'dashicons-building',
      'supports'            => array('title', 'editor', 'excerpt', 'author', 'thumbnail', 'revisions', 'custom-fields'),
      'public'              => true,
      'hierarchical'        => false,
      'show_ui'             => true,
      'show_in_menu'        => true,
      'show_in_nav_menus'   => true,
      'show_in_admin_bar'   => true,
      'has_archive'         => true,
      'can_export'          => true,
      'exclude_from_search' => false,
      'yarpp_support'       => true,
      'publicly_queryable'  => true,
      'capability_type'     => 'page',
      'with_front'          => false,
    ); 
    register_post_type( 'resource' , $args );
  }