I’m an experienced web developer, so I’m embarrassed to ask this, but why is my if statement cashing WordPress?
<!-- THE BLOCK FOR THE HEADER IN THE CMS !-->
<span class="PostHeader"><p>
<?php
if(empty(get_the_block("Header"))){
echo "Employment"; //Empty only on the employment screen
} else {
the_block("Header");
}
?>
</p>
<!-- END OF THE BLOCK -->
This is in a template for WordPress, and if I comment out the control structure, it loads fine, but as soon as I try to let it run in the template, the page just stops loading.
Why is it doing this?
–EDIT–
Sorry forgot to mention that the “Multiple Content Blocks” Plugin is enabled.
empty() is a structure not a function, it only accepts variables, you should use this instead:
For further informations see PHP Empty