title: How to show navigation on post_type=attachment on WordPress
body: <p>I am developing a stock photo page on WordPress and I want to display certain number of images per page and then show the navigation at the bottom. I can display the images properly without any problem but the navigation won't display at all. Here's what I have in my template page:</p>
  
  <p>
  
  <pre><code>                    $args = array(
                         'showposts' =&gt; 12,
                         'post_type' =&gt; 'attachment',
                         'paged'     =&gt; $paged
                        );
  
                        $attachments = get_posts( $args );
                           if ( $attachments ) {
                              foreach ( $attachments as $attachment ) {
                                 echo '&lt;li&gt;';
                                 echo '&lt;a class="th" title="';
                                 echo apply_filters( 'the_title', $attachment-&gt;post_title );
                                 echo '" href="';
                                 echo apply_filters( 'the_permalink', '?attachment_id='.$attachment-&gt;ID );
                                 echo '"&gt;';
                                 echo wp_get_attachment_image( $attachment-&gt;ID, 'thumbnail' );
                                 echo '&lt;/a&gt;';
                                 echo '&lt;/li&gt;';
                                }
                           }
                       ?&gt;
                      &lt;/ul&gt;
  
                      &lt;nav&gt;
                          &lt;?php previous_posts_link('&amp;laquo; Newer') ?&gt;
                          &lt;?php next_posts_link('Older &amp;raquo;') ?&gt;
                      &lt;/nav&gt;
  </code></pre>