Set class if a meta value is set within post archive
Question
I’m attempting to add a class to posts when the meta key ‘checkbox’ is clicked. Here’s what I have:
<?PHP $checkbox = get_post_meta($post->ID, 'checkbox', true);
if (!empty($checkbox)){ $has_video = 'icon-has_video'; }
else {$has_video = '';}
?>
<a class='<?php echo $has_video; ?>' href='<?php the_permalink(); ?>'>
… but so far it’s not working. Any suggestions?
0
3 months
0 Answers
18 views
0
Leave an answer
You must login or register to add a new answer .