我想创建一个自定义页面,它将显示20个最新的图库/页面-但只显示图库中的第一个图像,而不是所有图像。如下所示:http://www.autoblog.it/gallerie/
我已经这样做了:
<?php
$args = array(
'post_type' => 'attachment',
'posts_per_page' => 10,
'post_parent' => $postid,
'numberposts' => 1,
'paged' => $paged,
);
$attachments = get_posts($args);
if ($attachments) {
foreach ($attachments as $attachment) {
echo the_attachment_link($attachment->ID, false, false, true )
echo get_the_title(); }
}?>
它可以工作,但它所做的是显示最新的10个图像,而不是最新的10个画廊,所以每个画廊的第一张图像。
请帮帮忙
谢谢
发布于 2013-01-02 00:17:07
$args = get_children('post_type=attachment&post_mime_type=image&post_parent=‘( 'category_name’=> 'gallery‘);$q = new WP_Query($args);while ($q->have_=>()):$q->the_post();$iPostID = $post->ID;$arrImages =& array。$iPostID );if($arrImages) { $arrKeys = array_keys($arrImages);$iNum = $arrKeys;$sThumbUrl = wp_get_attachment_thumb_url($iNum);$sImgString = '‘。'‘。'';echo $sImgString;} endwhile;
希望它能有所帮助:)
发布于 2013-01-02 00:08:29
您必须尝试使用nextgen库:http://wordpress.org/extend/plugins/nextgen-gallery/
https://stackoverflow.com/questions/14110988
复制相似问题