简体   繁体   English

如何在WordPress“添加新帖子”页面中添加自定义字段?

[英]How to add custom fields in WordPress “Add a New Post” page?

I want to add a custom field on Add A New Post page. 我想在“添加新帖子”页面上添加自定义字段。

Like - if I am to make a plugin which will post links to Twitter after a new post is made, I would like to give ability to user to select if he wants to tweet that particular post's link to Twitter. 像-如果我要制作一个在发布新帖子后将链接发布到Twitter的插件,我希望用户可以选择是否要将该特定帖子的链接发布到Twitter。 I want to display a check box somewhere in the page which says - "Post this on Twitter" and then check for it and make a tweet. 我想在页面的某处显示一个复选框,该复选框为“在Twitter上发布此内容”,然后进行检查并发布一条推文。

I have seen some plugins which do this. 我已经看到一些插件可以做到这一点。 But can't remember which they were. 但是不记得他们是谁。

Can someone please help me out? 有人可以帮我吗?

查看add_meta_box()函数。

You can use this very helpful plugin to add custom fields. 您可以使用这个非常有用的插件来添加自定义字段。

http://wordpress.org/extend/plugins/more-fields/ http://wordpress.org/extend/plugins/more-fields/

Maybe this plugin can help you? 也许这个插件可以帮助您? http://wordpress.org/extend/plugins/tweet-this/ http://wordpress.org/extend/plugins/tweet-this/

I have finally figured how to achieve this 我终于想通了

You can use these hooks - 您可以使用这些挂钩-

submitpost_box } To display fields/form 显示字段/表单
submitpage_box } Submitpage_box}

edit_post } To process the form edit_post}处理表单
edit_page } edit_page}

Hope that helps! 希望有帮助!

Source - Kontera ContentLink WordPress plugin. 来源-Kontera ContentLink WordPress插件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM