post_type_labels( 'Mobilisation' ), 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => true, /*'menu_icon' => */ 'capability_type' => 'posts', 'has_archive' => true, 'hierarchical' => false, 'menu_position' => null, 'rewrite' => array("slug" => "mob"), // Permalinks 'query_var' => "mob", // This goes to the WP_Query schema 'supports' => array('title', 'editor', ) ); register_post_type( 'mob', $args ); } // A helper function for generating the labels function post_type_labels( $singular, $plural = '' ) { if( $plural == '') $plural = $singular .'s'; return array( 'name' => _x( $plural, 'post type general name' ), 'singular_name' => _x( $singular, 'post type singular name' ), 'add_new' => __( 'Ajouter ' ), 'add_new_item' => __( 'Ajouter une '. $singular ), 'edit_item' => __( 'Editer '. $singular ), 'new_item' => __( 'Nouvelle '. $singular ), 'view_item' => __( 'Voir une '. $singular ), 'search_items' => __( 'Search '. $plural ), 'not_found' => __( 'Aucune '. $plural .' trouvée' ), 'not_found_in_trash' => __( 'Aucune '. $plural .' trouvée dans la Corbeille' ), 'parent_item_colon' => '' ); } //add filter to ensure the text Book, or book, is displayed when user updates a book add_filter('post_updated_messages', 'post_type_updated_messages'); function post_type_updated_messages( $messages ) { global $post, $post_ID; $messages['mob'] = array( 0 => '', // Unused. Messages start at index 1. 1 => sprintf( __('Book updated. Afficher la mobilisation'), esc_url( get_permalink($post_ID) ) ), 2 => __('Custom field updated.'), 3 => __('Custom field deleted.'), 4 => __('Mobilisation mise .'), /* translators: %s: date and time of the revision */ 5 => isset($_GET['revision']) ? sprintf( __('Book restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, 6 => sprintf( __('Mobilisation publiée. Afficher la mobilisation'), esc_url( get_permalink($post_ID) ) ), 7 => __('Mobilisation sauvgardée.'), 8 => sprintf( __('Mobilisation soumise. Prévisualiser la mobilisation'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), 9 => sprintf( __('Mobilisation prevue pour: %1$s. Prévisualiser la mobilisation'), // translators: Publish box date format, see php.net/date date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ), 10 => sprintf( __('Brouillion de Mobilisation a été mis à jour. Prévisualiser la mobilisation'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), ); return $messages; } function category_automatically($post_ID) { global $wpdb; if(!has_term('','category',$post_ID)){ $category = get_term_by( 'slug', 'important', 'category' ); $cat = array($category->slug); wp_set_object_terms($post_ID, $cat, 'category'); } } add_action('publish_posts', 'category_automatically'); ?>