rewrite - WordPress - Custom Post Type and Taxonomy -
rewrite - WordPress - Custom Post Type and Taxonomy -
currently have create :
one new taxonomy : project one new post type : taskand want have :
// 1- list of all project www.example.com/projets/
// 2- see 1 project , list task www.example.com/projet/un-projet/
// 3- see 1 task of 1 project www.example.com/projet/un-projet/introduction/
number 1 , 2 don't work. how can this?
edit :i have add together in functions.php
<?php add_action( 'init', 'tache_type_register' ); /** * ajoute united nations type de post "les tâches" d'un projet * @link http://codex.wordpress.org/function_reference/register_post_type */ function tache_type_register() { $labels = array( 'name' => 'tâches', 'singular_name' => 'tâche', 'menu_name' => 'tâches', 'name_admin_bar' => 'tâche', 'add_new' => 'ajouter', 'add_new_item' => 'ajouter une nouvelle tâche', 'new_item' => 'nouvelle tâche', 'edit_item' => 'modifier la tâche', 'view_item' => 'voir la tâche', 'all_items' => 'toutes les tâches', 'search_items' => 'rechercher une tâche', 'parent_item_colon' => 'tâche parente:', 'not_found' => 'aucune tâche trouvée.', 'not_found_in_trash' => 'aucune tâche dans la corbeille.', ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'projet/%projet%' ), 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => false, 'menu_position' => 5, 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ), //'taxonomies' => array( 'category', 'post_tag' ) ); register_post_type( 'tache', $args ); } add_action( 'init', 'create_projet_taxonomies' ); /** * ajoute une taxonomie type pour les pour les projets * @link http://codex.wordpress.org/function_reference/register_taxonomy */ function create_projet_taxonomies() { $labels = array( 'name' => 'projets', 'singular_name' => 'projet', 'search_items' => 'rechercher united nations projet', 'all_items' => 'tous les projets', 'parent_item' => null, 'parent_item_colon' => null, 'edit_item' => 'modifier united nations projet', 'update_item' => 'mettre à jour', 'add_new_item' => 'ajouter united nations nouveau projet', 'new_item_name' => 'new genre name', 'menu_name' => 'projets', ); $args = array( 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'i/dont/know/here' ), ); register_taxonomy( 'projet', array( 'tache' ), $args ); } /* filtre pour modifier le permalink projet */ add_filter('post_link', 'projet_permalink', 1, 3); add_filter('post_type_link', 'projet_permalink', 1, 3); function projet_permalink($permalink, $post_id, $leavename) { if (strpos($permalink, '%projet%') === false) homecoming $permalink; // post $post = get_post($post_id); if (!$post) homecoming $permalink; // taxonomy terms $terms = wp_get_object_terms($post->id, 'projet'); if (!is_wp_error($terms) && !empty($terms) && is_object($terms[0])) $taxonomy_slug = $terms[0]->slug; else $taxonomy_slug = 'no-projet'; homecoming str_replace('%projet%', $taxonomy_slug, $permalink); } ?>
and now :
see 1 task of project (www.example.com/projet/homepi/introduction/) work see task of project (www.example.com/projet/homepi/) work see project (www.example.com/projet/) don't work
and don't know param rewrite of create_projet_taxonomy().
someone can help me , explain how can ? thanks
wordpress rewrite custom-post-type taxonomy custom-taxonomy
Comments
Post a Comment