• Hi,

    I’m using the in-built gallery shortcode (just using [shortcode] at the moment) to show a bunch of images on certain web pages – here is an example:
    http://www.doubleagents.org.uk/site/archives/151

    It works fine for the images, but on this page there are also attached various non-images (PDFs and a ZIP file) – is there any way of getting these other files listed on this page automatically?

    Many thanks in advance,
    Andrew

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter andrewfox

    (@andrewfox)

    Oh, a couple of other notes:
    1. I have to use the in-built image uploader.
    2. I’m happy for them to appear just as text links – not as icons

    Ta

    Thread Starter andrewfox

    (@andrewfox)

    Hmm… well I worked out a way of doing this…

    $attachments = get_posts($args);
    if ($attachments) {
    	$ifNonImage = 0;
    	foreach ($attachments as $attachment) {
    		if ( wp_attachment_is_image($attachment->ID ) ) {
    			// do nothing
    		} else {
    			if ($ifNonImage == 0) {
    				$ifNonImage = 1;
    				echo "<dl class=\"attachments\"><dt>Downloadable files</dt>";
    			}
    			$nonImageUrl = wp_get_attachment_url($attachment->ID);
    			$nonImageName = basename($nonImageUrl);
    			echo "<dd><a href=\"$nonImageUrl\">$nonImageName</a></dd>";
    		}
    	}
    	if ($ifNonImage == 1) {
    		echo "</dl>";
    	}
    } else {
    	// no attachments at all
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Showing non-images using the in-built gallery’ is closed to new replies.