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
You must download this plugin : http://downloads.wordpress.org/plugin/multiple-content-blocks.zip and install it.
The function you try to use aren’t in the WordPress Codex and are also not found. That’s why you get a blank page aka the white screen of death (also because php reporting_error is set to false). You can try to put this line
in front of your if else statement.
Material :
There is no function
get_the_block()
according to the WordPress Codex.Unless you’ve defined it or have a plugin that has defined it, you’re getting a fatal error. Your server’s error logs will likely confirm this.