vendredi 27 février 2015

Need help with get_posts pagination


I've been working on a wordpress site, and I'm trying to build a page where visitors can see all of the images that have been uploaded to the wordpress media gallery, regardless of whether or not said images are attached to any particular posts. The images from the query are showing up, but the pagination links are not. I can view the paginated pages by including page/2/ or page/3/ at the end of my URL, but the pagination links to bring viewers to those pages aren't showing up at all.


The gallery is located at http://ift.tt/1DhCwXw The images on http://ift.tt/1vG6KWJ and http://ift.tt/1DhCzmk are not the same images as the images on http://ift.tt/1DhCwXw so I assume pagination is possible here.


The code for the gallery template is as follows:



<?php
/*
Template Name: Gallery
*/
get_header(); ?>
<div class="main" role="main">
<div class="standard-section">
<div class="gallery">
<h1 class="big-centered-h1">Photo Category #1</h1>
<div class="gallery-images">
<?php
$gallery_page_args = array(
'post_type' => 'attachment',
'posts_per_page' => 8,
'paged' => $paged,
'post_mime_type' =>'image'
);
$the_gallery_page_attachments = get_posts($gallery_page_args);
if ($the_gallery_page_attachments) {
foreach ($the_gallery_page_attachments as $attachment) {
echo '<a class="img-lightbox-wrapper" href="';
echo wp_get_attachment_url($attachment->ID);
echo '">';
echo '<img class="gallery-image" src="';
echo wp_get_attachment_thumb_url($attachment->ID);
echo '">';
echo '</a>';
}
}
?>
<?php
echo '<div class="clearfix"></div>';
echo '<div class="left-pagination">';
previous_posts_link('Go back');
echo '</div>';
echo '<div class="right-pagination">';
next_posts_link('See More', $the_gallery_page_attachments->max_num_pages);
echo '</div>';
echo '<div class="clearfix"></div>';
?>
</div>
<div class="clearfix"></div>
</div>
</div>
</div>
<?php get_footer(); ?>


Any help would be greatly appreciated!





Aucun commentaire:

Enregistrer un commentaire