Categories in post_type
-
Anybody knows how can I list the categories from post_type in my sidebar?
This is my post_type code:
add_action('init', 'loja_register'); function loja_register() { $labels = array( 'name' => _x('Loja', 'post type general name'), 'singular_name' => _x('Loja Item', 'post type singular name'), 'add_new' => _x('Novo item', 'loja item'), 'add_new_item' => __('Adicionar Novo Item'), 'edit_item' => __('Editar Item'), 'new_item' => __('Novo Item'), 'view_item' => __('Ver Item'), 'search_items' => __('Buscar Loja'), 'not_found' => __('Nothing found'), 'not_found_in_trash' => __('Nothing found in Trash'), 'parent_item_colon' => '' ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, 'rewrite' => true, 'capability_type' => 'post', 'hierarchical' => false, 'menu_position' => null, 'supports' => array('title','editor') ); register_post_type( 'loja' , $args ); } //categorias register_taxonomy("Categorias", array("loja"), array("hierarchical" => true, "label" => "Categorias", "singular_label" => "Categorias", "rewrite" => true)); //campos do adicionar/editar posts add_action("admin_init", "admin_init"); function admin_init(){ add_meta_box("valor_produto-meta", "Valor", "valor_produto", "loja", "side", "low"); } function valor_produto(){ global $post; $custom = get_post_custom($post->ID); $valor_produto = $custom["valor_produto"][0]; ?> <label>Valor:</label> <input name="valor_produto" value="<?php echo $valor_produto; ?>" /> <?php } add_action('save_post', 'save_details'); function save_details(){ global $post; update_post_meta($post->ID, "valor_produto", $_POST["valor_produto"]); } //mostrar conteudo no admin add_action("manage_posts_custom_column", "loja_custom_columns"); add_filter("manage_edit-loja_columns", "loja_edit_columns"); function loja_edit_columns($columns){ $columns = array( "cb" => "<input type=\"checkbox\" />", "title" => "Produto", "description" => "Sobre", "valores" => "Valor", "categoriess" => "Categorias", ); return $columns; } function loja_custom_columns($column){ global $post; switch ($column) { case "description": the_excerpt(); break; case "valores": $custom = get_post_custom(); echo $custom["valor_produto"][0]; break; case "categoriess": echo get_the_term_list($post->ID, 'Categorias', '', ', ',''); break; } }
Thanks!
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Categories in post_type’ is closed to new replies.