include() (通常更安全include_once()) 返回是否成功。你看到了1 因为这是成功的返回值。顺便说一句,它回来了FALSE, 不0 失败时(不知道为什么)。
为了实现您想要实现的目标,@webaware的解决方案会起作用,但对于您想要实现的目标来说,一个不太全面(而且更有效的解决方案是使用file_get_contents() 像这样:
function build_total_search_method( $atts ) {
return file_get_contents( dirname(__FILE__) . "/includes/total_search.php" );
}
add_shortcode( \'total_search\', \'build_total_search_method\' );
请注意,我还去掉了这个额外的变量,因为它从未被使用过,而且我认为有了这一额外的行,它的可读性就会降低。