-
Book Overview & Buying
-
Table Of Contents
WordPress 2.8 Themes Cookbook
By :
WordPress themes should possess a number of different hooks by default, allowing active plugins to alter or add output when pages are rendered. WordPress development guidelines specify the names and locations of the expected WordPress hooks in themes.
There are three WordPress hooks that you need to add to almost every custom theme. They are:
wp_head
wp_footer
comment_form
First, add the wp_head hook. Find the end tag of the HTML head element (</head>, often in header.php) and place your cursor on the line before it. Insert the following:
<?php do_action( 'wp_head' ); ?>
Next, add the wp_footer hook. Find the end tag of the HTML body element (</body>, often in footer.php) and place your cursor on the line before it. Insert the following:
<?php do_action( 'wp_footer' ); ?>
Finally, insert the comment_form hook. Locate the end tag of the HTML form element for the comment form (</form>, often in comments.php and comments-popup.php) and place your cursor on the line before it. Insert the following:
<?php do_action( 'comment_form', $post->ID ); ?>
If you are using the default comments form layout, you won't have to explicitly add the comment_form hook because it is provided in the default theme's comments.php file.
Plugins use these hooks to add to or modify the rendered output of a theme's template files. Often the modification includes linking to or outputting JavaScript, CSS, or HTML code. Many popular plugins use the above hooks, and making sure that they are present is essential to the plugin's proper operation.
Although wp_head, wp_footer, and comment_form are the only hooks necessary for a complete theme, it is possible to add many more custom hooks that allow individuals to customize a theme after it has been fully developed by its author.
Change the font size
Change margin width
Change background colour