Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The best way to do this would be to use featured images:</p> <p>In your theme's functions.php file:</p> <pre><code>add_theme_support( 'post-thumbnails' ); // add theme support add_image_size( 'home-feature', 100, 100, true ); // add an image size </code></pre> <p>I've set the image size to be 100x100 - but obviously you change this to suit your needs</p> <p>See <a href="http://codex.wordpress.org/Function_Reference/add_theme_support" rel="nofollow">http://codex.wordpress.org/Function_Reference/add_theme_support</a> and <a href="http://codex.wordpress.org/Function_Reference/add_image_size" rel="nofollow">http://codex.wordpress.org/Function_Reference/add_image_size</a> for more info on these</p> <p>Then instead of <code>&lt;?php the_excerpt; ?&gt;</code> you would have:</p> <pre><code>&lt;?php if(has_post_thumbnail()) { the_post_thumbnail( 'home-feature' ); } else { // could show a standard image here - e.g. a grey box } ?&gt; </code></pre> <p>More info on this can be found here: <a href="http://codex.wordpress.org/Function_Reference/has_post_thumbnail" rel="nofollow">http://codex.wordpress.org/Function_Reference/has_post_thumbnail</a> and here: <a href="http://codex.wordpress.org/Function_Reference/the_post_thumbnail" rel="nofollow">http://codex.wordpress.org/Function_Reference/the_post_thumbnail</a></p> <p><em>UPDATE</em> Sorry just spotted that you said attachments, an option would be something along the lines of:</p> <pre><code>$args = array( 'post_type' =&gt; 'attachment', 'numberposts' =&gt; -1, // bring them all 'post_status' =&gt; null, 'post_parent' =&gt; $post-&gt;ID, // post id with the gallery 'orderby' =&gt; 'menu_order', 'order' =&gt; 'ASC' ); $attachments = get_posts($args); if(count($attachments) &gt; 0) { foreach((array)$attachments as $attachment) { ?&gt;&lt;li&gt;&lt;img src="&lt;?php print wp_get_attachment_url($img-&gt;ID); ?&gt;" width="448" height="290" alt="&lt;?php print $img-&gt;post_title;?&gt;" title="&lt;?php print $img-&gt;post_title;?&gt;"&gt;&lt;/li&gt;&lt;?php } } </code></pre> <p>Obviously in this foreach I've assumed all the attachments are images, but you could equally swap this out to just output the attachment</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload