如何只在某些页面上显示NextGEN Gallery插件的js

How to show js of NextGEN Gallery plugin only on certain pages

本文关键字:NextGEN 显示 Gallery 插件 js      更新时间:2024-04-04

我希望NextGEN Gallery的css和javascript文件只显示在某些页面上。我该怎么做?该插件有很多javascript文件,这会使网站速度变慢。

此解决方案不起作用:

if (is_page(48) || is_page(54) || is_page(4)) {
    wp_register_script('nextgen_lightbox_context', plugins_url('lightbox_context.js', __FILE__), array('jquery'), false, true);
    wp_enqueue_script('nextgen_lightbox_context');
    wp_register_script('photocrati_ajax', plugins_url('ajax.js', __FILE__), array('jquery'), false, true);
    wp_enqueue_script('photocrati_ajax');
}

我认为以下资源可以为您指明正确的方向:

http://wp.tutsplus.com/articles/tips-articles/quick-tip-conditionally-including-js-and-css-with-get_current_screen/