Quelques fragments de codes à utiliser dans le fichier functions.php de votre thème.
Chargement de scripts
function lfg_register_scripts() {
// Chargement de la feuille du style CSS
wp_enqueue_style('lfg-style', get_stylesheet_uri());
}
add_action('wp_enqueue_scripts', 'lfg_register_scripts');Changer l’intituler Articles dans la barre d’admin
// Fonction pour changer "Articles" par "Projets" dans la barre d'administration
function lfg_change_post_menu_label()
{
global $menu;
global $submenu;
$menu[5][0] = 'Projets';
$submenu['edit.php'][5][0] = 'Consulter les projets';
$submenu['edit.php'][10][0] = 'Ajouter un projet';
echo '';
}
add_action('admin_menu', 'lfg_change_post_menu_label');// Fonction pour changer les labels "Articles" par "Projets" dans les pages de l'administration
function lfg_change_post_object_label()
{
global $wp_post_types;
$labels = &$wp_post_types['post']->labels;
$labels->name = 'Projets';
$labels->singular_name = 'Projet';
$labels->add_new = 'Ajouter un projet';
$labels->add_new_item = 'Ajouter un projet';
$labels->edit_item = 'Modifier le projet';
$labels->new_item = 'Projet';
$labels->view_item = 'Voir le projet';
$labels->search_items = 'Recherche de projet';
$labels->not_found = "Il n'y a aucun projet";
$labels->not_found_in_trash = "Il n'y a aucun projet dans la corbeille";
}
add_action('init', 'lfg_change_post_object_label');Créer un modèle d’article (Gutenberg)
function lfg_register_my_block_template()
{
$post_type_object = get_post_type_object('post');
$post_type_object->template = array(
array('core/paragraph', array('placeholder' => 'Ecrivez ici', 'lock' => array('remove' => true, 'move' => true))),
array('core/gallery', array('lock' => array('remove' => true, 'move' => true)))
);
}
add_action('init', 'lfg_register_my_block_template');