From ffffe92af3b324b2033a50b60de374e9b457364a Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Mon, 4 Jan 2021 13:05:09 +0100 Subject: [PATCH] feat: ajout des romans Fixes #14 --- functions.php | 72 ++++++++++++++++++++++++++++++++++++++++++++++ page-roman.php | 71 +++++++++++++++++++++++++++++++++++++++++++++ taxonomy-roman.php | 66 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 209 insertions(+) create mode 100644 page-roman.php create mode 100644 taxonomy-roman.php diff --git a/functions.php b/functions.php index 090f076..f9e3b68 100644 --- a/functions.php +++ b/functions.php @@ -248,3 +248,75 @@ function kspace_update_profile_fields( $user_id ) { update_user_meta( $user_id, 'infodata', $_POST['infodata'] ); } + +/* 4. Romans + * + * Permet de catégoriser des chapitres ensemble, via une catégorie spécifiques. + * + */ + +register_taxonomy('roman', 'post', + array( + 'label' => 'Roman', + 'labels' => array( + 'name' => 'Romans', + 'singular_name' => 'Roman', + 'all_items' => 'Tous les romans', + 'edit_item' => 'Éditer le roman', + 'view_item' => 'Voir le roman', + 'update_item' => 'Mettre à jour le roman', + 'add_new_item' => 'Ajouter un roman', + 'new_item_name' => 'Nouveau roman', + 'search_items' => 'Rechercher parmi les romans', + 'popular_items' => 'Romans les plus utilisés'), + 'rewrite' => array('slug' => 'roman'), + 'hierarchical' => false, + 'public' => true, + 'hierarchical' => true, + 'show_in_nav_menus' => true, + 'has_archive' => true, + ) +); + + register_taxonomy_for_object_type( 'roman', 'post' ); + + // 1.2 - Ajout/Modif du niveau du flag + function romans_taxonomy_custom_fields($tag) { + // Check for existing taxonomy meta for the term you're editing + $t_id = $tag->term_id; // Get the ID of the term you're editing + $term_meta = get_option( "taxonomy_term_$t_id" ); // Do the check + ?> + + + + + + +
+ + + + + term_id; // Get the ID of the term you're editing + $term_meta = get_option( "taxonomy_term_$t_id" ); // Do the check + ?> + +
+ + +

.

+
+ + + +
+ + +
+ +
+ + + +
+ 'roman', + 'hide_empty' => false, + ) + ); + + // Check if any term exists + if ( ! empty( $terms ) && is_array( $terms ) ) { + // Run a loop and print them all + + foreach ( $terms as $term ) { ?> + + +
+
+ + + + diff --git a/taxonomy-roman.php b/taxonomy-roman.php new file mode 100644 index 0000000..6e11af0 --- /dev/null +++ b/taxonomy-roman.php @@ -0,0 +1,66 @@ + +
+ term_id;?> +
+ +
+ '; ?> +
+
+ + "> +
+
+

+
+ +
+
+ + array( + array( + 'taxonomy' => 'roman', + 'field' => 'term_id', + 'terms' => $tag_id // you need to know the term_id of your term "example 1" + ), + ), + 'posts_per_page' => -1, + 'order' => 'ASC', + ); + $query = new WP_Query( $args ); + ?> + +
+
Chapitres
+
+ have_posts()) : ?> + + have_posts()) : $query->the_post(); ?> + + + Chapitre . + + + + + + + + +
+
+ +
+
+ +