在WordPress后台为新作的主题创建主题菜单

操作代码如下:

  1. /**
  2. * 名称:在Wordpress后台为新作的主题创建主题菜单
  3. * 作者:原梓番
  4. * 博客:http://www.yuanzifan.com/
  5. * 最后修改:2019年12月6日
  6. */
  7.  
  8. add_action('admin_menu', 'add_theme_options_menu');
  9. function add_theme_options_menu() {
  10. add_theme_page(
  11. 'YZF主题设置', //页面title
  12. 'YZF主题设置', //后台菜单中显示的文字
  13. 'edit_theme_options', //选项放置的位置
  14. 'theme-options', //别名,也就是在URL中GET传送的参数
  15. 'theme_settings_admin' //调用显示内容调用的函数
  16. );
  17. }
  18. function theme_settings_admin()
  19. {
  20. require get_template_directory()."/settings/options-framework.php";
  21. }

需要你到主题目录下创建一个Settings,在下面创建一个options-framework.php的文件。在这个文件里写的东西,就可以做具体的设置。文章源自原紫番博客-https://www.yuanzifan.com/54524.html

效果如下:文章源自原紫番博客-https://www.yuanzifan.com/54524.html

文章源自原紫番博客-https://www.yuanzifan.com/54524.html 文章源自原紫番博客-https://www.yuanzifan.com/54524.html

站长微信
扫码添加(注明来意)
weinxin
Yuanzifan99
原梓番博客公众号
博客内容精选
weinxin
原梓番博客
 

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证
加载失败