Viewing 3 replies - 1 through 3 (of 3 total)
  • The answer would be “custom work” using WordPress functionality. This is pretty easy to achieve. Just plug the following code into your themes’ archives.php file make sure you overwrite the Loop that you have in there right now:

    <?php
    	/* WordPress Loop - Display only linked thumbnails
    	==================================================== */
    	if (have_posts()) :
    		while (have_posts()) : the_post(); update_post_caches($posts);
    			$images = get_children(
    				array(
    					'post_parent' => $post->ID,
    					'numberposts' => 1,
    					'post_status' => 'inherit',
    					'post_type' => 'attachment',
    					'post_mime_type' => 'image',
    					'order' => 'ASC',
    					'orderby' => 'menu_order'
    				)
    			);
    
    			if ( $images ) {
    				foreach ( $images as $id => $image ) {
    					$img = wp_get_attachment_thumb_url( $image->ID );
    					$link = get_permalink( $post->ID );
    					print "\n\n" . '<a  class="alignleft" href="' . $link . '"><img src="' . $img . '" alt="" />';
    				}
    
    			}
    		endwhile;
    		print '<div class="clear"></div>';
    	else :
    		print '<div class="errorbox">' . __('Sorry, no posts matched your criteria.') . '</div>';
    	endif;
    ?>

    Do you know how I could make this work with the listing of pages instead of posts?

    Solved my problem:

    <?php
    query_posts('post_type=page&post_parent='.$parent);
    ?>
    
    	<?php
    	/* WordPress Loop - Display only linked thumbnails
    	==================================================== */
    	if (have_posts()) :
    		while (have_posts()) : the_post(); update_post_caches($posts);
    
    			$images = get_children(
    				array(
    					'post_parent' => $post->ID,
    					'numberposts' => -1,
    					'post_status' => 'inherit',
    					'post_type' => 'attachment',
    					'post_mime_type' => 'image',
    					'order' => 'ASC',
    					'orderby' => 'menu_order'
    				)
    			);
    
    			if ( $images ) {
    				foreach ( $images as $id => $image ) {
    					$img = wp_get_attachment_thumb_url( $image->ID );
    					$link = get_permalink($page->ID);
    					echo "\n\n" . '<a  class="alignleft" href="' . $link . '"><img src="' . $img . '" alt="" /></a>';
    				}
    
    			}
    		endwhile;
    		echo '<div class="clear"></div>';
    	else :
    		echo '<div class="errorbox">' . __('Sorry, no posts matched your criteria.') . '</div>';
    	endif;
    ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to create a page that presents all post images?’ is closed to new replies.