简体   繁体   中英

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.
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.

Am I correct? How would I do this?

You can accomplish this with Settings API

You first have to add your option field with add_settings_field

Then you have to register it with register_setting

Then in comments.php you can use get_option to get the value of your field

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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