Hide Attachments DIV if no attachment added to post
-
Hi there, we have edited the snippet provided by you to integrate the attachments with our theme. we need some help with hiding the DIV if there is no attachment added to the post. At present is shows an empty space. Would you mind helping by providing an additional snippet we can add to our single.php
Our edited snippet below:
<!–Include Attachments to Post–>
<div class=”attachments”>
<?php $attachments = new Attachments( ‘attachments’ ); /* pass the instance name */ ?>
<?php if( $attachments->exist() ) : ?>
<h3>Attachments</h3>
</br>
<?php while( $attachments->get() ) : ?>
<h5>Name: <?php echo $attachments->field( ‘title’ ); ?></h5>
<h5>Size: <?php echo $attachments->filesize(); ?></h5>
<h5>url(); ?>”target=”_blank”>Download File</h5>
<?php endwhile; ?>
<?php endif; ?>
</div>
- The topic ‘Hide Attachments DIV if no attachment added to post’ is closed to new replies.