我想要一个画廊页面,其中所有的图像将显示,这是所有帖子上传。
我用页面模板尝试了这段代码,但这段代码的输出没有显示任何内容,甚至在我的浏览器中也没有显示HTML代码(不包括页眉和页脚):
<?php get_header();
/*
Template Name:Gallery
*/
while ( have_posts() ) : the_post();
if ( $post->post_type == \'data-design\' && $post->post_status == \'publish\' ) {
$attachments = get_posts( array(
\'post_type\' => \'attachment\',
\'posts_per_page\' => -1,
\'post_parent\' => $post->ID,
\'exclude\' => get_post_thumbnail_id()
) );
if ( $attachments ) {
foreach ( $attachments as $attachment ) {
$class = "post-attachment mime-" .
sanitize_title( $attachment->post_mime_type );
$thumbimg = wp_get_attachment_link( $attachment->ID, \'thumbnail-size\', true );
echo \'<li class="\' . $class . \' data-design-thumbnail">\' .
$thumbimg . \'</li>\';
}
}
}
endwhile;
get_footer(); ?>
如何制作此页面模板?