_x('Products', 'post type general name'), 'singular_name' => _x('product', 'post type singular name'), 'add_new' => _x('Add New', 'product'), 'add_new_item' => __('Add New Products'), 'edit_item' => __('Edit Products'), 'new_item' => __('New product'), 'view_item' => __('View Products'), 'search_items' => __('Search Products'), 'not_found' => __('No Products found'), 'not_found_in_trash' => __('No Products found in Trash'), 'parent_item_colon' => '' ); $product_args = array( 'labels' => $product_labels, 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'hierarchical' => false, 'rewrite' => true, 'supports' => array('title', 'editor', 'thumbnail'), 'taxonomies' => array( '' ), 'menu_icon' => get_bloginfo('template_directory') . '/images/products-icon.png', // Icon Path 'has_archive' => true ); register_post_type( 'product' , $product_args ); register_taxonomy( 'brands', 'product', array( 'hierarchical' => true, 'label' => __('Product Brands'), 'query_var' => 'brands' ) ); } add_action("admin_init", "admin_init"); add_action('save_post', 'save_points', 1, 2); function admin_init(){ add_meta_box("productInfo-meta", "Product Details", "product_meta_options", 'product', "normal", "high"); } function product_meta_options(){ global $post; $custom = get_post_custom($post->ID); $category = (!empty($custom["_category"][0])) ? $custom["_category"][0] : ''; $brand = (!empty($custom["_brand"][0])) ? $custom["_brand"][0] : ''; $id = (!empty($custom["_productid"][0])) ? $custom["_productid"][0] : ''; $features = (!empty($custom["_features"][0])) ? $custom["_features"][0] : ''; $holds = (!empty($custom["_holds"][0])) ? $custom["_holds"][0] : ''; ?>
Category
Brand
Product ID
Features 20) ); ?>
Holds 20) ); ?>
true, '_builtin' => false ); $post_types = get_post_types($args); if ( in_array($typenow, $post_types) ) { $filters = get_object_taxonomies($typenow); foreach ($filters as $tax_slug) { $tax_obj = get_taxonomy($tax_slug); wp_dropdown_categories(array( 'show_option_all' => __('Show All '.$tax_obj->label ), 'taxonomy' => $tax_slug, 'name' => $tax_obj->name, 'orderby' => 'term_order', 'selected' => $_GET[$tax_obj->query_var], 'hierarchical' => $tax_obj->hierarchical, 'show_count' => false, 'hide_empty' => true )); } } } function todo_convert_restrict($query) { global $pagenow; global $typenow; if ($pagenow=='edit.php') { $filters = get_object_taxonomies($typenow); foreach ($filters as $tax_slug) { $var = &$query->query_vars[$tax_slug]; if ( isset($var) ) { $term = get_term_by('id',$var,$tax_slug); $var = $term->slug; } } } return $query; } add_action( 'restrict_manage_posts', 'todo_restrict_manage_posts' ); add_filter('parse_query','todo_convert_restrict'); add_filter( 'manage_edit-product_columns', 'my_columns' ); function my_columns( $columns ) { $columns['brands'] = 'Brands'; $columns['category'] = 'Category'; unset( $columns['comments'] ); return $columns; } add_action( 'manage_posts_custom_column', 'populate_columns' ); function populate_columns( $column ) { if ( 'brands' == $column ) { $brand = esc_html( get_post_meta( get_the_ID(), 'brand', true ) ); echo $brand; } elseif ( 'category' == $column ) { $category = get_post_meta( get_the_ID(), 'category', true ); echo $category; } }