Skip to content

Instantly share code, notes, and snippets.

@vajrasar
Last active August 29, 2015 14:17
Show Gist options
  • Select an option

  • Save vajrasar/7ab682dd88420fbe2b28 to your computer and use it in GitHub Desktop.

Select an option

Save vajrasar/7ab682dd88420fbe2b28 to your computer and use it in GitHub Desktop.
[Envira Gallery] Title with Link to Image (LightBox) - Problem
<?php
/*
This was working fine, I was able to show Title of image with a hyperlink to image lightbox.
But suddenly from past a week site was down, when I checked error logs it stated
that the code (which was in my functions.php) is throwing error - PHP Parse error: syntax error, unexpected '['
That error was in Line 24 of this code.
*/
function envira_gallery_image_titles( $output, $id, $item, $data, $i ) {
// IDs of galleries to display titles on
$galleriesToShowTitles = array(
245
);
// Check if we need to display titles on this gallery
if ( !in_array( $data['id'], $galleriesToShowTitles ) ) {
return $output;
}
if ( isset( $item['title'] )) {
$output .= '<div class="title"><a href="' . $data['gallery'][$id]['link'] . '" class= "envira-gallery-245 envira-gallery-link" title="' . $item['title'] . '" rel="' . ['gallery'] . '" data-thumbnail>' . $item['title'] . '</a></div>';
}
return $output;
}
add_action( 'envira_gallery_output_after_link', 'envira_gallery_image_titles', 10, 5 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment