Beyond adding functionality or content to a site, the other major task commonly performed by plugins is to augment, modify, or reduce information before it is displayed on the screen. This is done by using WordPress filter hooks, which allow plugins to register a custom function through the WordPress API to be called, since content is prepared before it is sent to the browser. In this recipe, you will learn how to implement your first filter callback function to modify the contents of the generator meta tag that is output as part of the site header.
- Navigate to the WordPress plugin directory of your development installation.
- Create a new directory called
ch2-generator-filter
. - Navigate to this directory and create a new text file called
ch2-generator-filter.php
. - Open the new file in a code editor and add an appropriate header at the top of the plugin file, naming the plugin
Chapter 2 - Generator Filter
. - Add the following...