Wordpress +元框:对于每个字段值
我正在尝试获取每个克隆的值(按 + 添加)字段值,并希望重复视频嵌入代码。
首先我使用这个 WordPress 元框插件。 http://www.deluxeblogtips.com /2010/04/how-to-create-meta-box-wordpress-post.html
我有一个 CPT,我想使用一个代码来根据字段数显示。 CPT 上有一个文本元框,用户可以通过单击 + 按钮(意味着克隆)来添加更多内容。因此,对于每个字段,用户将输入不同的图像 ID 值。所以我想根据字段数重复我的代码。
因此,如果用户添加 3 个字段,它将重复代码 3 次。其中有这种结构。
<div>
<a href=""><img src="first-field-value" /></a>
</div>
因此,我想根据有多少现场用户创建并输入了该值来重复此结构。
如果我无法正确描述,我真的很抱歉。但如果您想了解更多信息,请告诉我。
I am trying to get value of each clone (adding by +) field value and want to repeat video embed code.
First I am using this wordpress meta box plugin.
http://www.deluxeblogtips.com/2010/04/how-to-create-meta-box-wordpress-post.html
I have a CPT where I want to use one code that will display as per the number of fields. There is a text meta box on CPT where user can add more by clicking on + button means clone. So for each field user will enter different value of image ID. So I want to repeat my code as per the number of field.
So if user adds 3 field it will repeat the code 3 times. which have something this structure.
<div>
<a href=""><img src="first-field-value" /></a>
</div>
So I want to repeat this structure as per how many field user created and entered the value for that.
I am really sorry if I unable to describe properly. But please let me know if you want to know something more than this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
http://farinspace.com/wpalchemy-metabox/ 上的 Wp Alchemy 类允许重复字段。
如果您自己滚动,则需要确保代表您的数据输入的表单字段以尾随“[]”命名,例如;我的字段名[]。这确保 php 将每个克隆项的值视为数组。
The Wp Alchemy class at http://farinspace.com/wpalchemy-metabox/ allows for repeating fields.
If you are rolling your own, you need to make sure that the form fields that represent your data entry are named with a trailing '[]', eg; myfieldname[]. This ensures that php treats the values for each cloned item as an array.