发布于 2021-05-05 12:56:38
语义
dis·play
在容易看到的地方展出(某物)。
这座宫殿过去常展出一系列佛兰芒语挂毯。
re·trieve
重新获得或带回(某物);重新占有
我被派去取回他花园里的球
多么
虽然header_image()会回显头图像URL,但get_header_image()不会。
<?php
header_image();
get_header_image();header_image()是get_header_image()的包装器。主要用于前端,角色是转义和回显get_header_image()。
<?php
/**
* Displays header image URL.
*
* @link https://developer.wordpress.org/reference/functions/header_image/
*/
function header_image() {
$image = get_header_image();
if ( $image ) {
echo esc_url( $image );
}
}get_header_image()的一个实际用例将在一个函数中。
WordPress在其大多数默认函数中使用get_ ...区分,例如:
get_the_title()和the_title().get_the_post_thumbnail()和the_post_thumbnail().get_the_content()和the_content()...。等。发布于 2021-05-05 12:59:14
我找到了答案。
然后有人很快就把它删除了,但只是为了让所有正在寻找答案的人受益:
header_image()将在不需要使用php echo的情况下回显echo。虽然get_header_image()也会返回图像URL,但是不回显它。您可以使用的来为它使用回显。
注意:官方文档中没有提到这一点,除非我是盲人,否则我向任何人挑战,让他们告诉我官方页面中echo的位置,或者解释这种区别的地方。
https://stackoverflow.com/questions/67400842
复制相似问题