echo category custom post type
-
Hello,
I try to add custom post type called ‘Projets’ in my theme i have create.
And i have created a taxonomy called ‘categories’ to add categories to my different projects.
All this in order to create a portfolio template.
Here is my functions.php :function portfolio_init() { $labels=array( 'name' => 'Projets', 'singular_name' => 'Projet', 'add_new' => 'Ajouter un projet', 'add_new_item' => 'Ajouter un nouveau projet', 'edit_item' => 'Modifier un projet', 'new_item' => 'nouveau projet', 'view_item' => 'Voir le projet', 'search_items' => 'Rechercher un projet', 'not_found' => 'Aucun projet trouvé', 'not_found_in_trash' => 'Aucun projet dans la corbeille', 'menu_name' => 'Mes projets' ); $args= array( 'labels' => $labels, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => true, 'capability_type' => 'post', 'hierarchical' => false, 'menu_position' => 3, 'supports' => array('title','editor', 'thumbnail', 'custom-fields') ); register_post_type('portfolio',$args); } add_action('init','portfolio_init'); function create_taxonomy() { $labels= array( 'name' => 'Catégories projets', 'singular_name' => 'Catégorie projet', 'search_items' => 'Rechercher une catégorie', 'all_items' => 'Toutes les catégories', 'edit_item' => 'Editer une catégorie', 'update_item' => 'Modifier une catégorie', 'add_new_item' => 'Ajouter une catégorie', 'new_item_name' => 'Nouvelle catégorie', 'menu_name' => 'Catégorie', ); register_taxonomy('Categories', array('portfolio'), array( 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'query_var' => true, 'rewrite' => array('slug' => 'categories') )); } add_action('init','create_taxonomy',0);
I can add a project in admin but i cannot see my categories in my template page portfolio.
Here is my portfolio.php :<ul class="filter-tabs filter-btns clearfix"> <li class="active filter" data-role="button" data-filter="all">Tous les projets</li> <?php $categories = get_terms('categories', array('order' => 'DESC')); foreach($categories as $cat) { ?> <li class="filter" data-role="button" data-filter=".<?php echo $cat->slug; ?>"><?php echo $cat->name; ?></li> <?php } ?> </ul>
But anything is on the screen…
Someone has ideas?
(Excuse for my english, i am french.)
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘echo category custom post type’ is closed to new replies.