Displaying the image descriptions on attachment page

The following code will display the description text field of any attachment at the bottom of the attachment page.

Copy and paste this snippet at the very bottom of your functions.php file. (if you are using a child theme, don’t forget to start your functions.php file with <?php )


add_action( '__after_content' ,'my_attachment_description' );

function my_attachment_description() {
global $post;
if ( ( isset($post) && 'attachment' != $post -> post_type) || !is_singular() || empty( $post->post_content ) )
<p class="text-center muted">
<?php echo strip_tags(apply_filters ('the_excerpt', $post->post_content)) ?>


8 thoughts on “Displaying the image descriptions on attachment page”

Comments are closed.