Taking WordPress Hooks To A Whole New Level! #
The Custom Hook Box option makes it not only super easy to create an unlimited number of Custom Hook Boxes, but then dictate their placement on your site using various Custom Conditionals (or if you don’t want to restrict their placement just leave your Conditionals un-selected).
How To Use… #
Give your Custom Hook Box a Name, select a Hook Location from the drop-down menu provided and then, if you would like to restrict the types of pages/posts your Custom Hook Box Content displays on, you can select various Conditionals you’ve created by checking the boxes in the Conditionals drop-down menu. Those few steps are all you need to take to successfully create a Custom Hook Box. Finally it’s just a matter of adding your custom content to the Hook Box Textarea. Here you can add any type of plain text and/or HTML and even javascript and PHP code!
What Happens When You Change The Name of A Custom Hook Box? #
The name of a Custom Hook Box acts as it’s ID so when you change that name it does not rename the Hook Box, but instead it creates a duplicate Custom Hook Box with the new name.
More Advanced… #
The Custom Hook Boxes option provides an advanced feature that you may find useful at some point. By setting a Priority you can gain even more control over the placement of your Custom Hook Boxes.
Sometimes you may add multiple Custom Hook Boxes and/or Custom Widget Areas to the same Hook Location. In these cases the Priority option becomes useful. When adding a Priority you should start with the number 10 as a baseline as this is usually the default Priority level in WordPress. You could give one Hook Box or Widget Area a Priority of 10 and another 11 or 9 and these Custom Content areas will display before or after accordingly.
Finally, you’ll notice that you can easily turn these Custom Hook Boxes on or off with the “Activate” option. This is useful when you don’t want to delete your Custom Hook Box, but would like to remove it from your site for the time being.
Can I Add PHP Code To My Custom Hook Boxes? #
Absolutely you can! Just be careful as you can temporarily “break” your site with incorrect PHP code.
“Custom CSS Box!” #
One very useful feature is the ability to simply add CSS code to your Custom Hook Box and have it automatically wrapped in the proper <style>tags</style>, minified for greatest efficiency, and hooked into the wp_head hook location. And with the Custom Conditionals and Labels at your disposal you can easily control where these styles affect your website! To use this feature all you have to do is name your Hook Box, select “CSS” in the drop-down menu to the right of the “Priority” option and then add your CSS code to the Hook Box’s textarea.
Shortcode #
To use a Shortcode to display a Hook Box, use: [your_hook_box_name_here] In other words, just take the Name you gave your Hook Box, change any capital letters to lowercase, change any spaces and/or dashes to underscores, and wrap it in square brackets.
[do_shortcode] Button #
To use shortcodes inside a Custom Hook Box you need to wrap the [shortcode] in the do_shortcode() function. A quick and easy way to do this is to simply click on the [do_shortcode] button. That will automatically wrap any text it finds wrapped in square brackets with that do_shortcode() function.
Note, however, that there may be cases where square bracketed text is not shortcode text in which case you’d either need to manually add the do_shortcode() function to any actual shortcodes in that Hook Box or just make sure to remove the do_shortcode() function code that is wrapped around any non-shortcode text.
**Important NOTE** #
Be sure that each of your Custom Hook Boxes has a name given to it. Failure to do this may result in the inability to Save your Custom Option settings.