• wordpress 自定义面板显示不了挂件区问题


    刚才在写一个wordpress主题,遇到一个问题。注册好的挂件区在控制面板(dashboard)上显示,在自定义面板上却不显示。
    查询了下,发现几个老外朋友也遇到了这个问题:

    浏览回复,发现并没有答复的人都没有找到问题是怎么产生的,所以都没有解决问题。直到一个哥们说了自己的个例,我才想明白是怎么回事。他说:

    I know you asked this a long time ago, but I just had the same issue, and finally figured out the problem. In my functions.php file, I had de-registered jquery (wp_deregister_script('jquery')). This apparently causes the widgets to not work in the customizer, even though my page was still loading jquery (through wp_enqueue_script).

    In order to fix the problem (assuming you're having the same problem as me), you need to re-register jquery by calling wp_register_script('jquery', ('url_to_jquery'), false, '1.11.1'[or whatever your jquery version is]).

    意思是说:我好像是取消加载jQuery,就出现这个问题,添加jQuery引用这个问题就解决了。

    虽然这不是问题的根源。但联想这几个问题,答案就呼之欲出了。

    • 后台dashboards可以看到挂件区,可见挂件区注册是没有问题的。
    • 为什么后台dashboards可以看到挂件区,而自定义下却看不到呢?一个是不加载页面,一个是加载页面。
    • 为什么移除jQuery失效,而添加引用则有效呢?估计是移除jQuery,导致没有依赖,脚本出错,阻断了页面其它脚本的执行

    于是我打开浏览器控制台,的确有脚本错误,解决后,自定义面板下的小工具挂件区就显示。

  • 相关阅读:
    京东css三角形做法
    css三角
    java 优势和劣势
    windows常用命令
    25 abstract 抽象
    24static 和final关键字之final
    面试题----static
    定义变量在前和定义变量在后
    java注解
    23static 和final关键词 之static 和运行顺序
  • 原文地址:https://www.cnblogs.com/flowerszhong/p/5370458.html
Copyright © 2020-2023  润新知