我一直在wordpress网站上工作,我正试图建立一个页面,让访问者可以看到上传到wordpress媒体库的所有图像,无论这些图像是否附在任何特定的帖子上。查询中的图像将显示,但分页链接不会显示。我可以通过在URL末尾包含第/2页或第/3页来查看分页的页面,但根本没有显示将访问者带到这些页面的分页链接。
画廊位于http://www.nickpassaro.com/clientsitedev/NJRI/gallery/上的图像http://www.nickpassaro.com/clientsitedev/NJRI/gallery/page/2/ 和http://www.nickpassaro.com/clientsitedev/NJRI/gallery/page/3/ 与上的图像不同http://www.nickpassaro.com/clientsitedev/NJRI/gallery/ 所以我假设分页在这里是可能的。
库模板的代码如下:
<?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
$paged = (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1;
$gallery_page_args = array(
\'post_type\' => \'attachment\',
\'posts_per_page\' => 8,
\'paged\' => $paged,
\'post_mime_type\' =>\'image\'
);
$gallery_page_query = get_posts($gallery_page_args);
if ($gallery_page_query) {
foreach ($gallery_page_query 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>\';
}
$gallery_page_pagination_args = array(
\'total\' => $gallery_page_query->max_num_pages,
\'prev_text\' => \'Go Back\',
\'next_text\' => \'See More\'
);
echo \'<div class="clearfix"></div>\';
echo paginate_links($gallery_page_pagination_args);
echo \'<div class="clearfix"></div>\';
}
?>
</div>
</div>
</div>
</div>
<?php get_footer(); ?>
任何帮助都将不胜感激!