Wordpress 自定义字段 管理视图中的默认字段
我已经编写了大量与模板一起使用的自定义字段,但它们不会立即显示在页面/帖子的管理视图中,我必须手动输入所有自定义字段名称。
有没有办法自动使我的字段显示在管理视图中,以便我可以立即从下拉列表中选择它们?
I have written a ton of custom fields to use with a template, but they are not showing up immediately in the admin view of the Page/Post and I have to manually type in all of the custom field names.
Is there a way to automatically make my fields show in the admin view, so I can immediately choose them from the dropdown?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
更好的方法可能是执行以下操作。将其添加到主题的functions.php文件http://pastebin.com/NyqS2uPr - 代码相当长,抱歉。
添加后,您会看到帖子下现在有一个新的“自定义”菜单。在此输入项目将允许您添加自定义字段(由代码确定)。这比只有下拉菜单要干净一些,因为您可以预先确定自定义字段名称。
A better way may be to do the following. Add this to your themes functions.php file http://pastebin.com/NyqS2uPr - Code was rather long, sorry.
Once you add that, you'll see that under posts there is now a new "custom" menu. Entering items into this will allow you to add custom fields (determined by the code). This is a little cleaner than just having the dropdown as you can pre-determine what the custom field names will be.
虽然我通常会将自定义字段添加到functions.php 文件中,但我之前成功使用过的另一个选项是使用免费插件添加它们。我发现的最好的自定义字段插件称为“更多字段”。 更多字段插件可在 wordpress.org 上找到,并且非常易于使用(并且不需要任何实际编码)。如果您更喜欢的话,还有更多插件可以选择。
如果您想走 .htaccess 路线或插件路线,这确实是您的决定。两者都有各自的优点,但我至少想分享我过去很幸运的插件。
While I'll usually add custom fields to the functions.php file, another option I've successfully used before is to add them using a free plugin. The best custom fields plugin I've found is called "More Fields". The More Fields plugin is available on wordpress.org and its very easy to use (and doesn't require any actual coding). There are a few more plugins you can also choose from if you like them better.
It's really your call on if you want to go the .htaccess route or the plugin route. Both have their advantages, but I wanted to at least share the plugin I've had good luck with in the past.