In the question How to add code to Header.php in a child theme?, a recommended solution is to create a plugin, then hook into wp_head
action by using this code:
add_action('wp_head', 'wpse_43672_wp_head');
function wpse_43672_wp_head(){
//Close PHP tags
?>
ADD YOUR PLAIN HTML CODE HERE
<?php //Open PHP tags
}
Looking at header.php, I see that <?php wp_head(); ?>
belongs to <head>
, not <body>
. So which function to use if I want to hook into the body? I don't see any <?php wp_body(); ?>
in header.php, though I find there is <?php wp_footer(); ?>
right before </body>
in footer.php.
My goal is to add these code, in order to use the Off Canvas Sidebars plugin:
<body>
<?php do_action('website_before'); ?>
<!-- WEBSITE CONTENT -->
<?php do_action('website_after'); ?>
<?php wp_footer(); ?>
</body>