WordPress plugins take advantage of plugin API hooks placed in themes so they can execute various commands inside the plugin and/or get and write information to your website.
To make sure our markup and code are able to play well with various plugins, we need to include a hook in each of the header.php
and footer.php
files as follows:
In header.php
, just before the closing </head>
tag, add the following:
<?php wp_head(); ?>
In footer.php
, right before your closing </body>
tag, add the following:
<?php wp_footer(); ?>
We added the wp_head
and wp_footer
hooks in the header.php
and footer.php
files respectively.
The wp_head
hook is used by many plugins to add elements to <head>
such as styles, scripts, and meta tags.
Plugins generally use the wp_footer
hook to reference JavaScript files.
As we've mentioned, WordPress makes use of a variety of content types including pages, posts, and attachments. You can create specific template files to display each of these.
The most commonly used template file in addition to index.php
is probably page.php
, which is used to display static pages. This is because you'll often find that a static page doesn't need to display all of the information shown in a single post or archive listing, such as metadata or comments.
Let's have a look at how one of our static pages looks right now, using index.php
:
Currently, it's displaying the text This Month: plus a comment count, a Read more link, and the author metadata. We want to remove those.
So the final step we'll take in this chapter is to create a page.php
file based on our index.php
file, which WordPress will use to display all static pages correctly.