通常,您可以在注册操作后取消注册该操作的回调,然后在调用之前注册自己的回调do_action( \'...\' )
.
下面是一个示例:
// Add your own with later priority, e.g. 11 or wrap it in another later hook:
add_action( \'amp_post_template_head\', \'wpse_amp_post_template_add_canonical\', 11 );
function wpse_amp_post_template_add_canonical( $amp_template )
{
// Remove the unwanted callback:
remove_action( \'amp_post_template_head\', \'amp_post_template_add_canonical\' );
// Modify this new output to your needs:
printf(
\'<link rel="canonical" href="%s" />\',
esc_url( $amp_template->get( \'canonical_url\' ) )
);
}