【发布时间】:2016-08-23 06:43:59
【问题描述】:
我想更改 get_header_image_tag 函数的输出以输出我想要的确切 HTML。我还希望能够将数据添加到输出中,例如尚未涵盖的新 srcset...
我尝试使用apply_filters get_header_image_tag 对其进行测试,但无法正常工作:
apply_filters('get_header_image_tag', "<img src>", get_custom_header(), ['url' => 'test']);
echo get_header_image_tag();
我非常确信我对 apply_filters 工作原理的理解可能是那里的问题......我一直在阅读它,但我无法理解这些参数。我在网上找到的大多数示例只使用了一个钩子和一个值。
按照我的理解,我希望输出为<img src=url>,方法是使用get_custom_header() 中的数据并将URL 属性替换为'test'。
但是,输出的是默认的 get_header_image_tag。我也尝试直接回显 apply_filters:
echo apply_filters('get_header_image_tag', "<img src>", get_custom_header(), ['url' => 'test']);
然后,只输出<img src>...
【问题讨论】:
标签: php wordpress wordpress-theming hook