It still doesn’t seem to work. I am just going to do it without shortcodes and use the code you posted earlier. Thank you for helping.
It still isn’t working. This code is being put in shortcode content by the shortcoder plugin btw if it helps.
Thanks for helping but actually, I meant for the function to be inside the <script>
tag.
Maybe something like this?:
<p id="message"></p>
<script>
if (get_field('video_id')) {
?><?php
} else {
document.getElementById("message").innerHTML = "Video unavailable";
// Only display "Video unavailable when field "video_id" is empty"
}
</script>
The code above does not work I think because the plugin I am using does not support php. I need to do it with javascript if that is possible.
@morgyface Thanks, that’s exactly what I meant.