Created
June 28, 2014 14:20
-
-
Save patrickgilmour/2b52f89af50967848c40 to your computer and use it in GitHub Desktop.
Revisions
-
patrickgilmour created this gist
Jun 28, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ <?php /** * Get the Alt text of a Featured Image * * And other image attributes */ add_action('genesis_before_sidebar_widget_area', 'pgwp_genesis_before_sidebar_widget_area' ); function pgwp_genesis_before_sidebar_widget_area () { $img_id = get_post_thumbnail_id( get_the_ID() ); //Note: you may need other methods to get id $alt_text = get_post_meta( $img_id, '_wp_attachment_image_alt', true ); if(count( $alt_text )) echo $alt_text; // Show other image attributes, using get_post() - different from above // echo get_post( get_post_thumbnail_id() )->post_title; // echo get_post( get_post_thumbnail_id() )->post_excerpt; // echo get_post( get_post_thumbnail_id() )->post_content; }