WORDPRESS:“自定义字段”是我投资组合的解决方案吗? [英] WORDPRESS: Is Custom Fields the solution for my portfolio?

查看:82
本文介绍了WORDPRESS:“自定义字段”是我投资组合的解决方案吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我要做的事情的简要说明:

Here's a brief explanation of what I'm trying to do:

我的主页上会有大约12张缩略图,其中包括标题,简短说明,也许还有网址(已安排) 3 x 4或其他值)。我希望每个条目都链接到我的single.php页面,该页面将显示有关每个项目的更多详细信息,并带有多个较大的图像文件,这些文件将在项目描述的右侧显示标题。

My homepage will have about 12 thumbnail images with title, short description, maybe web url (arranged 3 x 4 or whatever). I want each of these entries to link to my single.php page which will show more details about each project, with multiple larger image files that will display with captions to the right of the project description.

我想解决此问题的最佳方法是使用功能图像作为主页上的缩略图显示,该缩略图现在似乎正在工作,但我一直在尝试找出自定义字段用于其他图像(image1,image2,image3)。我不知道。我希望能够从一个屏幕输入新作品集的所有内容和图像。

I'm thinking the best way to approach this would be to use the 'featured image' for the thumbnail display on the homepage which seems to be working now, but I've been trying to figure out Custom Fields to use for my other images (image1, image2, image3). I can't figure it out. I want to be able to enter all the content and images for a new portfolio piece from one screen. Possible?

这可行吗?如果是这样,怎么办?即使在网上阅读了大量有关自定义字段的信息后,自定义字段也确实使我感到非常困惑。

Is this doable? If so, how? The Custom Fields are confusing me really badly at this point, even after reading tons of articles online about it.

我非常感谢您的投入!我似乎无法破解,而且有点令人沮丧。 :P

I'd really appreciate some input! I can't seem to crack this and it's getting a bit frustrating. :P

推荐答案

自定义字段是每个帖子键值对。因此,您当然可以将它们用于此目的。例如,您可以使用与建议的名称完全相同的自定义字段:image1,image2等。请注意,自定义字段的通用性确实使这至少有些尴尬,但这仍然是您的最佳选择。

Custom fields are per post key-value pairs. So you could certainly use them for this purpose. For instance, you could have custom fields named exactly as suggested: image1, image2, etc. Note that the generic nature of custom fields does make this at least a little awkward, but it is probably still your best option.

这些关键字必须在某个地方进行处理,听起来好像您的single.php是执行此操作的地方。本质上,single.php是自定义帖子模板,因此您可以提取自定义字段数据并根据需要进行呈现。您将需要编写PHP代码来做到这一点,并且习惯阅读WordPress 功能参考

Those keywords must be processed somewhere, and it sounds as if your single.php is the place to do it. Essentially your single.php is a custom post template, so you can extract the custom field data and render it as you wish. You will need to write PHP code to do this, and be comfortable in reading the WordPress function reference.

get_post_meta 函数可能是最相关的

您想要做的事情并不困难,但是第一次却很难。那是因为您将在此过程中学习WordPress的各种细微差别。

What you want to do isn't difficult, but is hard to do the first time. That's because you will be learning all sorts of little nuances of WordPress along the way.

这篇关于WORDPRESS:“自定义字段”是我投资组合的解决方案吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆