WordPress.org

Ready to get started?Download WordPress

Forums

Paginated attachment archive (2 posts)

  1. boykenan
    Member
    Posted 1 year ago #

    I'm trying to create an archive for the built-in attachment post type. I'd like to display the (let's say) 50 images most recently uploaded to the site, with a link to the next 50, and so on. Can it be done?

  2. RGB Media
    Member
    Posted 1 year ago #

    Just create new page template with this code -

    <?php
    	$attachments = array(
    		'post_type' => 'attachment',
    		'post_status' => array('publish', 'draft', 'inherit'),
    		'numberposts' => -1,
    		'posts_per_page' => 10,
    		'paged' => $paged,
    	);
    	query_posts($attachments);
    
    	if (have_posts()) : while (have_posts()) : the_post();
    ?>
    
    CODE TO DISPLAY YOUR ATTACHMENT
    
    <?php endwhile; else: ?>
    
    NO ATTACHMENTS
    
    <?php endif; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic