首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Wordpress -显示最新的10个图库

Wordpress -显示最新的10个图库
EN

Stack Overflow用户
提问于 2013-01-01 21:45:50
回答 2查看 1.4K关注 0票数 0

我想创建一个自定义页面,它将显示20个最新的图库/页面-但只显示图库中的第一个图像,而不是所有图像。如下所示:http://www.autoblog.it/gallerie/

我已经这样做了:

代码语言:javascript
运行
复制
<?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个画廊,所以每个画廊的第一张图像。

请帮帮忙

谢谢

EN

回答 2

Stack Overflow用户

发布于 2013-01-02 00:17:07

  1. Create galleries页面
  2. 检索附加了画廊的所有帖子(例如,将它们添加到画廊类别)
  3. 在页面中,只检索画廊类别中的所有帖子:

$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;

希望它能有所帮助:)

票数 2
EN

Stack Overflow用户

发布于 2013-01-02 00:08:29

您必须尝试使用nextgen库:http://wordpress.org/extend/plugins/nextgen-gallery/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14110988

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档