WordPress:每个帖子显示 5 个附件
我知道这可能是一个简单的问题,但我是 WordPress 编码和 PHP 的初学者。我希望在我的网站上的每个帖子中嵌入五个附件,所以我知道这与向 single.php 或 loop.php 中插入某些内容有关。假设我在帖子中附加了 8 或 10 张照片,我希望单个帖子页面显示其中 5 张照片,并有一个指向“gallery”/attachment.php 页面的链接。就像这个网站在这个页面上所做的那样,帖子条目末尾的 6 张照片 (http://www.celebuzz.com/2011-05-27/kim-kardashian-kris-humphries-makes-first-post -engagement-public-appearance-photos/)
我尝试过使用 wordpress [图库] 插入,但它所做的只是显示所有图片,我不想使用插件,因为我觉得它太过分了,而且它只需要是一些调用 5 张附加照片的代码。希望有人能帮忙。提前致谢
I know this may be a simple question but I am a total beginner at Wordpress coding and PHP. I am looking to embed five attachments to each post on my site, so I know it has got to do with inserting something into single.php or loop.php. So let's say I have 8 or 10 photos attached to a post, I want the single post page to show 5 of those photos and have a link to the 'gallery'/attachment.php page. Something like what this website does on this page, the 6 photos at the end of the post entry (http://www.celebuzz.com/2011-05-27/kim-kardashian-kris-humphries-makes-first-post-engagement-public-appearance-photos/)
I have tried using the wordpress [gallery] insert but all it does is show all the pictures and I don't want to use a plugin because I feel that it is overkill and all it needs is some code to call up 5 attached photos. Hope someone can help. Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用自定义字段模板插件
http://wordpress.org/extend/plugins/custom-field-template/
Try using custom field template plugin
http://wordpress.org/extend/plugins/custom-field-template/
我知道你不想使用插件。但是,为了提出问题,我知道有人最终会从搜索引擎登陆这里。
您可以使用附件插件。这个插件非常简单而且非常直接。
安装后,它将在帖子创建页面上添加新的元框。
您可以添加任意数量的图像和模板页面的
循环
部分,您可以添加以下代码段:I know you don't want to use plugin. But, for the sake of the questions and I know someone will eventually landed here from search engine.
You can use attachment plugin. This plugin is quite simple and very straightforward.
Once installed, it will add new meta box on post creation page.
You can add as much as images you like and
the loop
part of your template page, you add this snippet: