Home › Forums › Front-end Issues › If checkbox ticked then add a class › Reply To: If checkbox ticked then add a class
Huzzah! I had a friend have a look at it and not only did he clean up my code, he also solved the problem. I’ll post it here for anyone that may be stuck on the same thing.
PHP
<?php
$args = array(
'post_type' => 'Videos'
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
echo '<div class="grid-item thumb ';
foreach (get_the_terms(get_the_ID(), 'category') as $cat) { echo $cat->slug . ' '; }
echo '"><a href="';
the_field('vid_url');
echo '" data-lity data-signed="';
echo get_field('vid_signed') ? 'true' : 'false';
echo '" data-director="';
foreach (get_the_terms(get_the_ID(), 'director') as $cat) { echo $cat->name; }
echo '" data-title="';
the_title();
echo '">';
the_post_thumbnail();
echo '</a></div>';
endwhile;
?>
JAVASCRIPT
jQuery(document).on('lity:ready', function(event, lightbox) {
var $target = jQuery(event.currentTarget.activeElement),
director = lightbox.opener().data('director'),
title = lightbox.opener().data('title'),
signed = lightbox.opener().data('signed');
$target.find('.lity-container').prepend('<div class="lity-hover"><div class="lity-info"><h1>' + director + '</h1><h2>' + title + '</h2></div></div>');
if ( !signed ) {
$target.find('.lity-container h2').after('<h3>Here is a line about getting in contact</h3>');
}
});
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.