Created
April 30, 2017 20:24
-
-
Save gregoirenoyelle/b2b4d95a588d15580d776715fa4a36a3 to your computer and use it in GitHub Desktop.
Genesis Ajouter une image à la une avant le titre
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//* Modèle pour les single | |
// Afficher l'image à la une | |
add_action( 'genesis_entry_header', 'gnoyelle_image_une', 9 ); | |
function gnoyelle_image_une() { | |
// Regarde si l'image à la une existe | |
// Sinon, le script s'arrête | |
if ( ! has_post_thumbnail() ) { | |
return; | |
} | |
// Données de l'image | |
$image_id = get_post_thumbnail_id(); | |
$image_url = wp_get_attachment_url( $image_id ); | |
$img = wp_get_attachment_image( $image_id, 'large' ); | |
// Afficher l'image | |
printf('<a href="%s">%s</a>', $image_url, $img); | |
} | |
genesis(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment