Home » Wordpress » How to check post or page has an attachment in wordpress

Here is code to check post or page has an attachment in wordpress. You have to in wordpress loop.

1
2
3
4
5
6
7
<?php
if ( is_attachment() ) {
    echo 'Has an Attachment';
} else {
    echo 'Not has an Attachment';
}
?>

Array ( [0] => Wordpress )