Skip to content

Instantly share code, notes, and snippets.

@thomasgriffin
Created February 5, 2014 00:43
Show Gist options
  • Save thomasgriffin/8815376 to your computer and use it in GitHub Desktop.
Save thomasgriffin/8815376 to your computer and use it in GitHub Desktop.
Disables lightbox functionality for a specific gallery ID.
<?php
add_filter( 'envira_gallery_pre_data', 'tgm_envira_disable_lightbox', 10, 2 );
function tgm_envira_disable_lightbox( $data, $gallery_id ) {
// You can target this by specific ID if you want. If you want this for all galleries, just remove this line. Change 324 to your gallery ID.
if ( 324 !== $gallery_id ) {
return $data;
}
// Empty the link field for each image.
foreach ( (array) $data['gallery'] as $id => $item ) {
if ( ! empty( $data['gallery'][$id]['link'] ) ) {
unset( $data['gallery'][$id]['link'] );
}
}
// Return the modified data.
return $data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment