If you want LB for special pages, you’ll need a “hook” to activate a script on that pages only
.
But firstly, you should know, how many pages will use that plugin (is this a static number of pages or dynamic). If there are several pages, it wouldn’t be so hard.
To do that, you need:
1) create a new .js file from your script (which I put in the last message) with a name, for example, “lightbox_plus.js”. Put this file in “template_directory”/js
2) In functions.php add the following (but read before placing):
/* Enqueue scripts (and related stylesheets) */
add_action( 'wp_enqueue_scripts', 'my_lightbox_script' );
function my_lightbox_script() {
wp_register_script('lightbox_plus', get_stylesheet_directory_uri() . '/js/lightbox_plus.js', false, null, true);
/* here you need to place a slug from url to set an "anchor". Or you can use an ID of a page */
if (is_page('page-slug-here')){
wp_enqueue_script('lightbox_plus');
}}
I hope it’ll help.