2013-08-16 94 views
1

我们目前正在开发wordpress plugin。但是,在旧版本的WordPress的,但它的CSS工作正常,未在wordpress 3.6无法加载css在wordpress 3.6

对于加载CSS加载我们使用代码:

global $wp_query; 
    $posts = $wp_query->posts; 
    $pattern = get_shortcode_regex(); 

    foreach ($posts as $post) 
    { 
     if (preg_match_all('/'. $pattern .'/s', $post->post_content, $matches) && array_key_exists(2, $matches) && in_array('MYSHORCODE', $matches[2])) 
     { 
      wp_enqueue_style('ap-bootstrap-css',plugins_url('menu-pages/bootstrap-assets/css/bootstrap-appointpress.css', __FILE__)); 
      wp_enqueue_script('ap-jquery.min.js',plugins_url('menu-pages/bootstrap-assets/js/jquery.min.js', __FILE__)); 
      wp_register_style('ap-bootstrapoverlay-css',plugins_url('overlay.css', __FILE__)); 
      wp_enqueue_style('ap-bootstrapoverlay-css'); 
     }  
    } 

我怎样才能解决这个问题呢?

编辑

我只得到,如果我只在侧边栏或页脚

+0

您的wp-config.php文件又被你加载插件足够早在WordPress的初始化过程?例如,使用代码'add_action(“init”,“myplugin”);'如果在过程中加载插件的时间太晚,CSS可能会错过。 – fred2

回答

0

使用简码这个问题不会通过帖子循环加载CSS和JS,但单独的所有帖子。此代码会使网站崩溃。

无法看到其余的代码,它看起来像你的入侵也是错误的。

在上WP_DEBUG

define('WP_DEBUG', true);