Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action ( 'genesis_after_header', 'sk_featured_image', 9 );
- /**
- * Display Featured image after header
- * only on the first page when the Page or Post is divided into multiple using <!--nextpage-->
- *
- * Scope: static Pages and single Posts.
- *
- * @author Sridhar Katakam and Gary Jones
- * @link http://sridharkatakam.com/, http://gamajo.com/
- */
- function sk_featured_image() {
- if ( has_post_thumbnail() && ( is_page() || is_single() ) && 0 === get_query_var( 'page' ) ) {
- // Get the URL of featured image
- $image = genesis_get_image( 'format=url' );
- // Get the alt text of featured image
- $thumb_id = get_post_thumbnail_id( get_the_ID() );
- $alt = get_post_meta( $thumb_id, '_wp_attachment_image_alt', true );
- // If no alt text is present for featured image, set it to Post/Page title
- if ( '' == $alt ) {
- $alt = the_title_attribute( 'echo=0' );
- }
- // Display featured image
- printf(
- '<div class="my-featured-image"><img src="%s" alt="%s" class="aligncenter" /></div>',
- esc_url( $image ),
- $alt
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement