我使用Code Snippets 插件使管理注入的代码变得更容易


add_action( \'wp_head\', function () { ?>
<!-- head script here -->
<?php } );
add_action( \'wp_body_open\', function () { ?>
<!-- body script here -->
<?php } );
Note: 这使用了较新的
wp_body_open
WordPress 5.2(2019年5月)中引入了钩子,请确保您的WordPress是5.2以上版本,并且您的主题不会太旧。