Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter jasonday

    (@jasonday)

    Accomplished it this way:

    <?php $attachments = get_posts( array(
                'post_type' => 'attachment',
                'posts_per_page' => -1,
                'post_parent' => $post->ID,
                'exclude'     => in_array('image', 'audio')
    			));
    
    			if ( $attachments ) { ?>
    				   <div id="listing-documents">
    					<?php echo do_shortcode( '[dg]' ); ?>
    					</div>
    				<?php } ?>
    Plugin Author Dan Rossiter

    (@danrossiter)

    Hi Jason,

    What you’ve done works, but why not just call [dg] always? DG will handle no attachments correctly (no output). ??

    Changing to this approach would also avoid double work since internally DG is calling get_posts().

    -Dan

    Thread Starter jasonday

    (@jasonday)

    Hi Dan,

    thanks for responding. I’m displaying the output inside a tabbed interface. If there is no attachment, then I don’t want the corresponding tab to show.

    Plugin Author Dan Rossiter

    (@danrossiter)

    Ah-ha! Then yes, what you’ve described is the way to go! ??

    -Dan

    PS: If you’ve found this plugin useful, please take a moment to rate it. Thanks! ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to check if there are documents attached to post?’ is closed to new replies.