As you transcribe code segments from the pages of this book or start writing your own plugins, there is a strong chance that you will have to troubleshoot problems with your code or have trouble working with data that your plugin is meant to manipulate. This recipe shows the basic techniques to identify and quickly resolve these errors while creating a plugin that will hide an item from the navigation menu for users who are not logged in to your site.
- Navigate to the WordPress plugin directory of your development installation.
- Create a new directory called
ch2-nav-menu-filter
. - Navigate to this directory and create a new text file called
ch2-nav-menu-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 - Nav Menu Filter
.
- Add the following line of code to register a function that will be called when WordPress is preparing data to display...