我需要为我的 WordPress 主题创建自定义标头。但我需要通过插件来完成。就像我的插件中有预构建头一样。我需要将其设置为标题,并且需要删除主题默认标题。
我到处研究,但找不到任何资源。
请使用以下代码从插件加载标头。
add_action('get_header', function(){
require PLUGIN_DIR.'includes/templates/header.php';
$templates = [];
$templates[] = 'header.php';
remove_all_actions( 'wp_head' );
ob_start();
locate_template( $templates, true );
ob_get_clean();
});