Adding custom post types (CPT) without a plugin
You should find a new custom post type listed to the side of your admin menu.
<?php
////////////////////////////////////////////////////////
// Custom Post Types
////////////////////////////////////////////////////////
// Add CPT Products
add_action( 'init', 'register_cpt_services' );
function register_cpt_services() {
$labels = array(
'name' => __( 'services', 'text_domain' ),
'singular_name' => __( 'service', 'text_domain' ),
'add_new' => _x( 'Add New', '${4:Name}', 'text_domain' ),
'add_new_item' => __( 'Add New', 'text_domain}' ),
'edit_item' => __( 'Edit', 'text_domain' ),
'new_item' => __( 'New', 'text_domain' ),
'view_item' => __( 'View', 'text_domain' ),
'search_items' => __( 'Search', 'text_domain' ),
'not_found' => __( 'No post type name found', 'text_domain' ),
'not_found_in_trash' => __( 'No post type name found in Trash', 'text_domain' ),
'parent_item_colon' => __( 'service:', 'text_domain' ),
'menu_name' => __( 'Services', 'text_domain' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'description' => 'description',
'taxonomies' => array( 'service-categorys' ), //Assigning the new service categories
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-heart', //menu icons
'rewrite' => array( 'slug' => 'single-service' ),
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
//'rewrite' => true,
'capability_type' => 'post',
//'show_in_menu' => 'options-general.php', // set post type as sub menu item
);
register_post_type( 'services_cpt', $args );
flush_rewrite_rules();
}
?>
Awesome!
Now lets link up some ACF Fields to this CTP menu item.
Joseph