DigitalRefresh
9/13/2018 - 6:00 PM

Add Custom Post Type #cpt #cust

// Create Custom Post Type
function register_custom_posts_init() {

      $supports = array(
      'title', // post title
      'editor', // post content
      'author', // post author
      'thumbnail', // featured images
      'excerpt', // post excerpt
      'custom-fields', // custom fields
      'comments', // post comments
      'revisions', // post revisions
      'post-formats', // post formats
      );
       
      $labels = array(
\!h      'name' => _x('__news__', 'plural'),
\!h      'singular_name' => _x('__news__', 'singular'),
\!h      'menu_name' => _x('__news__', 'admin menu'),
\!h      'name_admin_bar' => _x('__news__', 'admin bar'),
      'add_new' => _x('Add New', 'add new'),
\!h      'add_new_item' => __('Add New __news__'),
\!h      'new_item' => __('New __news__'),
\!h      'edit_item' => __('Edit __news__'),
\!h      'view_item' => __('View __news__'),
\!h      'all_items' => __('All __news__'),
\!h      'search_items' => __('Search __news__'),
\!h      'not_found' => __('No __news__ found.'),
      );
       
      $args = array(
      'supports' => $supports,
      'labels' => $labels,
      'public' => true,
      'query_var' => true,
\!h      'rewrite' => array('slug' => '__news__'),
      'has_archive' => true,
      'hierarchical' => false,
      );
    register_post_type('news', $args);
  }
  add_action('init', 'register_custom_posts_init');