Last active
October 17, 2015 07:45
-
-
Save bradonomics/2678fa9a1356549b9d68 to your computer and use it in GitHub Desktop.
This code is for the Genesis Framework and, as written, will not work on any other WordPress installation. I was looking for a way to add an image larger than the content area above the content area yet below the post title. Add the code in the functions.php file to your child theme functions file and when a post has a featured image it will pul…
This file contains 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 | |
//* Adds Feature Image before entry-content tag | |
add_action ( 'genesis_entry_header', 'bw_featured_image' ); | |
function bw_featured_image() { | |
if ( !is_singular() || !has_post_thumbnail() ) | |
return; | |
echo '<div class="featured-image">'; | |
genesis_image( array( 'size' => 'singular' ) ); | |
$args = array( 'post_type' => 'attachment', 'orderby' => 'menu_order', 'order' => 'ASC', 'post_mime_type' => 'image' ,'post_status' => null, 'numberposts' => null, 'post_parent' => $post->ID ); | |
$attachments = get_posts($args); | |
if ($attachments) { | |
foreach ( $attachments as $attachment ) { | |
$alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true); | |
$caption = $attachment->post_excerpt; | |
} | |
} | |
echo '<p class="wp-caption-text">' . $caption . '</p></div>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment