Skip to main content

🗂️ Structure de projet

Arborescence des dossiers

Structure recommandée d'un projet WordPress

mon-projet-wordpress/
├── wp-content/
│ ├── themes/
│ │ ├── parent-theme/ # Thème parent
│ │ ├── style.css # Styles des pages du thème enfant
│ │ ├── functions.php # Fonctions personnalisées
│ │ ├── templates/ # Templates personnalisés
│ │ ├── parts/ # Template parts
│ │ ├── assets/ # Ressources statiques
│ │ │ ├── css/
│ │ │ ├── js/
│ │ │ └── images/
│ │ └── inc/ # Fichiers d'inclusion
│ ├── plugins/
│ │ ├── custom-plugin/ # Plugins personnalisés
│ │ └── [plugins-tiers]/
│ ├── uploads/ # Médias téléchargés
├── wp-config.php # Configuration WordPress
├── .htaccess # Règles Apache

Conventions de nommage

Fichiers et dossiers

Méthodologie de nommage recommandée mais pas obligatoire :

  • Dossiers : kebab-case (ex: custom-post-types)
  • Fichiers PHP : kebab-case.php (ex: custom-functions.php)
  • Fichiers CSS/SCSS : kebab-case.scss (ex: main-styles.scss)
  • Fichiers JS : camelCase.js (ex: customScript.js)
  • Images : kebab-case + descriptif (ex: -banner-home.jpg)

Templates WordPress

  • Pages : {slug}.php (ex: contact.php)
  • Articles : single-{post-type}.php (ex: single-produit.php)
  • Archives : archive-{post-type}.php (ex: archive-actualite.php)
  • Taxonomies : taxonomy-{taxonomy}.php (ex: taxonomy-categorie-produit.php)

Classes CSS

Méthodologie BEM recommandée mais pas obligatoire :

/* Block */
.card { }

/* Element */
.card__title { }
.card__content { }

/* Modifier */
.card--featured { }
.card__title--large { }

Custom Post Types & Taxonomies

  • CPT : singulier, snake_case (ex: produit, temoignage)
  • Taxonomies : pluriel, snake_case (ex: categories_produit, tags_blog)

Champs ACF

  • Groupes : {page/post-type}_{contexte} (ex: page_home_hero, produit_specifications)
  • Champs : {contexte}_{type}_{nom} (ex: hero_text_title, produit_image_gallery)

Variables et constantes

PHP :

// Variables
$ma_variable = 'valeur';
$tableau_donnees = array();

JavaScript :

// Variables
const myVariable = 'value';
let dataArray = [];

// Constantes
const THEME_CONFIG = {
version: '1.0.0',
breakpoints: {
mobile: 768,
tablet: 1024
}
};

Bonnes pratiques

  1. Préfixage : Toujours préfixer les fonctions, classes et variables avec le nom de l'agence
  2. Lisibilité : Utiliser des noms explicites et descriptifs
  3. Cohérence : Respecter les conventions si possible dans tout le projet
  4. Documentation : Commenter les fonctions complexes