- This topic has 4 replies, 2 voices, and was last updated 4 years, 6 months ago by Tom.
-
AuthorPosts
-
March 25, 2020 at 1:31 pm #1210054charlotte
Hi!
I am not a great developer who masters everything on the fingertips, but I do not do too bad I think …
I used to my fourth site on wordpress and I admit that identifying certain things is part of the obstacle course.I prefer to create a custom post type with custom category taxonomy rather than playing with the blog.
here is my code found a little to the right to the left:
// Register Custom Post Type function video_post_type() { $labels = array( 'name' => _x( 'Vidéos', 'Post Type General Name', 'text_domain' ), 'singular_name' => _x( 'Vidéo', 'Post Type Singular Name', 'text_domain' ), 'menu_name' => __( 'Vidéos', 'text_domain' ), 'name_admin_bar' => __( 'Vidéo', 'text_domain' ), 'archives' => __( 'Item Archives', 'text_domain' ), 'attributes' => __( 'Attributs de la vidéo', 'text_domain' ), 'parent_item_colon' => __( 'Vidéo parente :', 'text_domain' ), 'all_items' => __( 'Toutes les vidéos', 'text_domain' ), 'add_new_item' => __( 'Ajouter une nouvelle Vidéo', 'text_domain' ), 'add_new' => __( 'Ajouter', 'text_domain' ), 'new_item' => __( 'Nouvelle vidéo', 'text_domain' ), 'edit_item' => __( 'Modifier la vidéo', 'text_domain' ), 'update_item' => __( 'Mettre à jour la vidéo', 'text_domain' ), 'view_item' => __( 'Voir la vidéo', 'text_domain' ), 'view_items' => __( 'Voir les vidéos', 'text_domain' ), 'search_items' => __( 'Rechercher la vidéo', 'text_domain' ), 'not_found' => __( 'Aucune vidéo trouvée', 'text_domain' ), 'not_found_in_trash' => __( 'Aucune vidéo trouvée dans la corbeille', 'text_domain' ), 'featured_image' => __( 'Image mise en avant', 'text_domain' ), 'set_featured_image' => __( 'Définir l\'image mise en avant', 'text_domain' ), 'remove_featured_image' => __( 'Retirer l\'image mise en avant', 'text_domain' ), 'use_featured_image' => __( 'Utiliser comme image mise en avant', 'text_domain' ), 'insert_into_item' => __( 'Insérer dans la vidéo', 'text_domain' ), 'uploaded_to_this_item' => __( 'Uploaded to this item', 'text_domain' ), 'items_list' => __( 'Items list', 'text_domain' ), 'items_list_navigation' => __( 'Items list navigation', 'text_domain' ), 'filter_items_list' => __( 'Filter items list', 'text_domain' ), ); $args = array( 'label' => __( 'Vidéo', 'text_domain' ), 'description' => __( 'video type.', 'text_domain' ), 'labels' => $labels, 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_rest' => true, 'supports' => array('title', 'editor', 'thumbnail', 'comments','excerpt'), 'taxonomies' => array( 'video_category' ), 'menu_position' => 5, 'menu_icon' => 'dashicons-video-alt3', 'show_in_admin_bar' => true, 'show_in_nav_menus' => true, 'can_export' => true, 'has_archive' => true, 'exclude_from_search' => false, 'publicly_queryable' => true, 'capability_type' => 'page', ); register_post_type( 'video', $args ); } add_action( 'init', 'video_post_type', 0 ); // Register Custom Taxonomy function video_category_taxonomy() { $labels = array( 'name' => _x( 'Catégories', 'Taxonomy General Name', 'text_domain' ), 'singular_name' => _x( 'Catégorie', 'Taxonomy Singular Name', 'text_domain' ), 'menu_name' => __( 'Catégories', 'text_domain' ), 'all_items' => __( 'Toutes les catégories', 'text_domain' ), 'parent_item' => __( 'Catégorie parente', 'text_domain' ), 'parent_item_colon' => __( 'Catégorie parente :', 'text_domain' ), 'new_item_name' => __( 'New Manufacturer Name', 'text_domain' ), 'add_new_item' => __( 'Ajouter une nouvelle catégorie', 'text_domain' ), 'edit_item' => __( 'Modifier la catégorie', 'text_domain' ), 'update_item' => __( 'Mettre à jour la catégorie Manufacturer', 'text_domain' ), 'view_item' => __( 'View Item', 'text_domain' ), 'separate_items_with_commas' => __( 'Séparer les catégories par des virgules', 'text_domain' ), 'add_or_remove_items' => __( 'Ajouter ou supprimer des catégories', 'text_domain' ), 'choose_from_most_used' => __( 'Choose from the most used manufactures', 'text_domain' ), 'popular_items' => __( 'Popular Items', 'text_domain' ), 'search_items' => __( 'Rechercher dans les catégories', 'text_domain' ), 'not_found' => __( 'Aucune catégorie trouvée.', 'text_domain' ), 'no_terms' => __( 'No items', 'text_domain' ), 'items_list' => __( 'Items list', 'text_domain' ), 'items_list_navigation' => __( 'Items list navigation', 'text_domain' ), ); $args = array( 'labels' => $labels, 'hierarchical' => true, 'public' => true, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'show_tagcloud' => true, 'show_in_rest' => true, ); register_taxonomy( 'video_category', array( 'video' ), $args ); } add_action( 'init', 'video_category_taxonomy', 0 );
I think my question is simple: how to display my categories taxonomy on the custom post page, like on the blog…
I test bits of code found everywhere, I think I start to understand the operation but nothing works!
I beg you on your knees, gods of the code, illuminate me with your holy light.
March 25, 2020 at 4:41 pm #1210176TomLead DeveloperLead DeveloperHi there,
This might help: https://generatepress.com/forums/topic/how-do-i-display-a-custom-taxonomy-on-my-single-posts/#post-1194051
Let me know 🙂
March 25, 2020 at 4:47 pm #1210188charlottehi!
thanks for your answer but this is the jungle this thread!
a lot of bad code, whitout a true explanation… a disucssion between geek
why post the wrong code?I’ve tested lots of bits of code, but something I must escape. yet I know how to do in php :
echo the_terms($post->ID, 'video_category');
but I can’t find how to do this with generatepressMarch 26, 2020 at 7:49 am #1210775charlotteI replied to me even as I finally find how to do it SIMPLY!
my Custom Post Type is call “video”.
my Custom Taxonomy is call “video_category”.you need to activate the module elements:
- on menu “appearance”, select item “generatepress”;
- on list of modules, locate the line “elements” and click on the button “enable”.
now it is necessary to add an element:
- in menu “appearance”, select item “elements”;
- create a new one;
- on code section, past this code:
- <span class=”cat-links” style=”margin-top: 34px;”>
<span class=”screen-reader-text”>Catégories </span>
<?php echo the_terms($post->ID, ‘video_category’); ?>
</span>
- <span class=”cat-links” style=”margin-top: 34px;”>
- on “settings” section:
- on item “hook”, select “after_entry_header”on popup menu;
- on item “execute PHP”, click on checkbox.
- on “Display rules” section:
- on item “location”, select your Custom Taxonomy on first popup menu, and select “all” on second popup menu.
- save your new element!
and enjoy!
March 26, 2020 at 9:50 am #1210976TomLead DeveloperLead DeveloperGlad you found a solution – thanks for sharing it 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.