在WordPress PHP中,是否可以以任何方式捕获get_header的输出


In WordPress PHP, can the output from get_header be captured in any way?

我注意到,使用 wp_list_categories()wp_get_archives()wp_list_pages() 可以将 'echo=0' 指定为参数字符串的一部分,从而能够在回显到输出流之前抓取内容进行进一步处理。

是否有类似的机制可用于get_header()?或者,有没有办法在将评估的标头代码返回到浏览器之前捕获它?我正在尝试做的是修改 HTML 中<title>标记的内容。

Wordpress有一个标题的过滤器钩

<?php 
function filter_function_name( $title, $sep, $seplocation ){
  $title .= get_bloginfo( 'name' );
  return $title;
}
add_filter( 'wp_title', 'filter_function_name', 10, 2 ); ?>

用于wp_title过滤器钩子的WordPress API