Hide specific element from frontend when a filed is checked with ACF

Question

I added a checkbox to my ACF. the ACF shows on the admin post pages.
I have embed tag(video) on the content of some posts. I want to display embed off in frontend whenever I check the check box.

I set it with ACF and jQuery as the following codes but I am curious Are it possible with ACF plugin without jQuery?

if( get_field(‘checkbox’) ) {
// .wp-video{display==none}
//or better if all embed tag not wok on post content
}

I put it on single.php

<?php
if( get_field('checkbox') ) {
echo '<div id="msg"></div>';
}
?>

after that help jQuery:

if ($('#msg').length > 0) {
$('div.content-body > div.wp-video').hide();
}
0
D.JCode 8 months 2020-11-24T11:10:38-05:00 0 Answers 13 views 0

Leave an answer

Browse
Browse