让函数返回HTML,而不是回显它。执行函数中的逻辑以查看图像/徽标是否存在,如果存在,则仅返回HTML,否则返回null/false。
function my_header_function( $output = false ) {
     if ( /*image and logo have been uploaded */ ) {
          $output = /* HTML of your hero header */;
     }
     return $output;
}
 向钩子函数添加检查,查看函数是否返回内容;如果有,请回音。
if ( function_exists( \'my_header_function\' ) && ( $hero = my_header_function() ) ) {
     echo $hero;
}