A common action performed by plugins is to add extra content to the header of visitor-facing pages generated by WordPress. This recipe shows you how to register an action hook function to be able to add such additional content. To make this example more concrete, we will use the Google Analytics page header JavaScript code that so many people use to get good page view statistics for their site.
Adding output content to page headers using plugin actions
How to do it...
- Navigate to the WordPress plugin directory of your development installation.
- Create a new directory called ch2-page-header-output.
- Navigate to this directory and create a new text file called ch2-page-header-output.php.
- Open the new file in a code editor and...