Bonjour, si vous êtes ‘à l’aise » avec les extraits de code, il y cette solution sur github
Je vous donne le code ci-dessous (à ajouter dans le fichier function.php. ATTENTION, je ne sais pas si cela fonctionne avec votre thème, je l’ai testé avec le thème Storefront, la légende s’affiche en bas, à gauche de l’image mise à la une).
/*ajout légende img en une*/
add_filter( 'post_thumbnail_html', 'custom_add_post_thumbnail_caption',10,5 );
function custom_add_post_thumbnail_caption($html, $post_id, $post_thumbnail_id, $size, $attr) {
if( $html == '' ) {
return $html;
} else {
$out = '';
$thumbnail_image = get_posts(array('p' => $post_thumbnail_id, 'post_type' => 'attachment'));
if ($thumbnail_image && isset($thumbnail_image[0])) {
$image = wp_get_attachment_image_src($post_thumbnail_id, $size);
if($thumbnail_image[0]->post_excerpt)
$out .= '<div class="wp-caption thumb-caption">';
$out .= $html;
if($thumbnail_image[0]->post_excerpt)
$out .= '<p class="wp-caption-text thumb-caption-text">'.$thumbnail_image[0]->post_excerpt.'</p></div>';
}
return $out;
}
}
Ensuite vous ajouter une légende à votre média (votre image), vous mettez à jour et cela devrait s’afficher.
Je joins une capture d’écran (la légende est Image par rose-de-velours (Pixabay))
Fichiers joints :
Vous devez être
connecté pour voir les fichiers joints.