[英]How to create admin menu item in wordpress to insert info into theme file
I am trying to integrate a comments policy section on my website. 我正在尝试在我的网站上整合评论政策部分。 I currently manually entered in by adding some php code on comments.php in my child theme.
我目前通过在我的子主题中的comments.php上添加一些php代码手动输入。
However, What I would like to accomplish is to create an admin menu item that allows me to change the message in the admin menu any time i need to make changes to the comment policy. 但是,我想要完成的是创建一个管理菜单项,允许我在需要更改注释策略时更改管理菜单中的消息。
I am guessing there should be a way to have a form on an admin menu page to fill out that will define a param, then in comments.php
call that param to echo on the page. 我猜应该有一种方法可以在管理菜单页面上填写一个表单来定义一个param,然后在
comments.php
调用该param以在页面上回显。
Am I correct? 我对么? How would I do this?
我该怎么做?
You can accomplish this with Settings API 您可以使用Settings API完成此操作
You first have to add your option field with add_settings_field 首先必须使用add_settings_field添加选项字段
Then you have to register it with register_setting 然后,你必须有注册它register_setting
Then in comments.php
you can use get_option
to get the value of your field 然后在
comments.php
您可以使用get_option
来获取字段的值
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.