Displaying the image descriptions on attachment page

⚠️ Code snippets might not be compatible with the latest version of your theme. Always use a child theme to customize your theme, and test your code on a staging website before migrating to production.

You can search the user’s forum or ask the user community by opening a new thread in the Customizr theme forum. Before opening a new topic, you might want to follow the troubleshooting steps..

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.