function evenements_post_type() { $labels = array( 'name' => __('Évènements', 'ryad-almaarifa'), 'singular_name' => __('Évènement', 'ryad-almaarifa'), 'menu_name' => __('Évènements', 'ryad-almaarifa'), 'name_admin_bar' => __('Évènement', 'ryad-almaarifa'), 'add_new' => __('Ajouter un nouveau', 'ryad-almaarifa'), 'add_new_item' => __('Ajouter un nouveau Évènement', 'ryad-almaarifa'), 'new_item' => __('New Évènement', 'ryad-almaarifa'), 'edit_item' => __('Edit Évènement', 'ryad-almaarifa'), 'view_item' => __('View Évènement', 'ryad-almaarifa'), 'all_items' => __('All Évènements', 'ryad-almaarifa'), 'search_items' => __('Search Évènements', 'ryad-almaarifa'), 'parent_item_colon' => __('Parent Évènements:', 'ryad-almaarifa'), 'not_found' => __('No Évènements found.', 'ryad-almaarifa'), 'not_found_in_trash' => __('No Évènements found in Trash.', 'ryad-almaarifa') ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => array('slug' => 'evenements'), 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => false, 'menu_position' => null, 'supports' => array('title', 'editor', 'thumbnail', 'excerpt'), 'menu_icon' => 'dashicons-calendar-alt', ); register_post_type('evenements', $args); } add_action('init', 'evenements_post_type'); // Add custom fields for ÉVÈNEMENTS function add_event_custom_fields() { add_meta_box( 'event_document_field', "Présentation de l'événement", 'event_document_field_callback', 'evenements', 'normal', 'default' ); add_meta_box( 'event_location_field', "Lieu de l'événement", 'event_location_field_callback', 'evenements', 'normal', 'default' ); } function event_document_field_callback($post) { // Get the existing value of the document field $event_document = get_post_meta($post->ID, '_event_document', true); // Display the input field echo ''; echo ''; } function event_location_field_callback($post) { // Get the existing value of the location field $event_location = get_post_meta($post->ID, '_event_location', true); // Display the input field echo ""; echo ''; } function save_event_custom_fields($post_id) { // Save the document field if (isset($_POST['event_document'])) { update_post_meta($post_id, '_event_document', esc_url($_POST['event_document'])); } // Save the location field if (isset($_POST['event_location'])) { update_post_meta($post_id, '_event_location', sanitize_text_field($_POST['event_location'])); } } add_action('add_meta_boxes', 'add_event_custom_fields'); add_action('save_post', 'save_event_custom_fields');