Create custom post type.
Add in function.php. menu_icons see in WordPress Codex.
<?php
/*------------------------------------*\
Custom Post Type
\*------------------------------------*/
/* register */
function products_cpt() {
register_post_type( 'products', array(
'labels' => array('name' => 'Models','singular_name' => 'Model',),
'rewrite' => array( 'slug' => 'product' ),
'public' => true,
'menu_position' => 20,
'menu_icon' => 'dashicons-cart',
'supports' => array( 'title', 'editor', 'author', 'custom-fields', 'thumbnail' ),
'publicly_queryable' => 'true',
'query_var' => true
));
}
add_action( 'init', 'products_cpt' );
register_taxonomy(
'product_categories',
'products',
array(
'hierarchical' => true,
'label' => 'Categories',
'query_var' => true,
'rewrite' => true
)
);
/* allow filtering in WP backend */
/**
* Display a custom taxonomy dropdown in admin
* @author Mike Hemberger
* @link http://thestizmedia.com/custom-post-type-filter-admin-custom-taxonomy/
*/
function tsm_filter_post_type_by_taxonomy() {
global $typenow;
$post_type = 'products'; // change to your post type
$taxonomy = 'product_categories'; // change to your taxonomy
if ($typenow == $post_type) {
$selected = isset($_GET[$taxonomy]) ? $_GET[$taxonomy] : '';
$info_taxonomy = get_taxonomy($taxonomy);
wp_dropdown_categories(array(
'show_option_all' => __("Show All {$info_taxonomy->label}"),
'taxonomy' => $taxonomy,
'name' => $taxonomy,
'orderby' => 'name',
'selected' => $selected,
'show_count' => true,
'hide_empty' => false,
'value_field' => 'slug',
'hierarchical' => 1
));
};
}
add_action('restrict_manage_posts', 'tsm_filter_post_type_by_taxonomy');
?>