如何在 WordPress 中创建缩略图页面
我正在创建一个 WordPress 照片博客主题,并且想要创建一个位于 index.php 和 single.php 之间的缩略图页面。
这个想法是,当有人单击博客文章时,他们会转到缩略图页面以查看该文章附加的所有照片,然后单击单个图像以重定向到博客条目。 WP 模板支持这个吗?
I'm creating a WordPress photoblog theme and I want to create a thumbnails page that sits between index.php and single.php.
The idea is that when someone clicks on a blog post, they go to the thumbnails page to see all photos attached to that post and they then click on an individual image to be redirected to the blog entry. Does WP templating support this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
WordPress 只是加载主题目录中的文件,因此您不会受到 WP 的太多限制。
如果您愿意,为什么不让
index.php
文件有一个仅在收到表示用户已请求缩略图页面的$_GET
变量时运行的部分呢?这就是我的意思:
single.php:
在
index.php
上,您可以将gallery
参数添加到 URL:但是我就是这么做的。
WordPress just loads the files inside of the theme's directory, so you aren't limited by WP much.
If you want, why not just make the
index.php
file have a section which runs only when it receives a$_GET
variable denoting that the user has requested the thumbnails page?This is sort of what I mean:
single.php:
And on
index.php
, you could add thegallery
parameter to the URLs:But that's just the way I'd do it.
我不明白“用户点击博客文章”是什么意思,但简而言之,您可以修改主模板来编写如下链接:
然后编写一些自定义插件来管理每个博客文章的一组照片。
最后,创建一个“showphotos”页面并将其分配给主题文件,并添加必要的 PHP 代码以在其中生成缩略图。
你的问题的问题在于你问的问题类似于“我如何建造一座木塔”?有不同的方法,每种方法都取决于不同的用例,您的问题都没有具体解决这些方法。不要忘记,我们不是来为您创建插件的,所以不要要求复杂的系统,而是专注于困扰您的问题。
I don't see what you mean by "the user clicks on a blog post", but in short, you could modify the main template to write a link like:
Then write some custom plugin to manage a set of photos per blog post.
Finally, create a page "showphotos" and assign it to a theme file and add the necessary PHP code to generate the thumbnails inside of it.
The problem with your question is that you're asking something similar to "how do I build a wooden tower"? There are different ways, and each depend on different use cases, none of which are specifically tackled by your question. Don't forget that we on SO are not here to create plugins for you, so don't ask for elaborate systems and instead focus on what's bugging you.