I have a simple loop on my search.php. When you click on the link, the photoswipe lightbox appears:

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); 

if ( in_category( 'photography')) {
$attachment_data = wp_prepare_attachment_for_js( $attachment->ID );
echo'<figure class="photoswipe"><a href="'.$attachment_data['url'].'">
more specific html goes here</a></figure>';
}

endwhile; endif; ?>

For some reason, the lightbox only works with the removal of this line:

if ( in_category( 'photography')) {}

With that removed, the lightbox buttons are clickable again. Nothing else on the page has changed, and the ui is suddenly functional.

I also noticed this issue is isolated to browsers over a year old (Firefox 48, Chrome 49). Is there any reason for something like this to occur? Any fix?

For reference, the photoswipe lightbox: here.

Read more here: PHP if statement affecting lightbox


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: