When building a website using WordPress, you’ll often have a piece of content that doesn’t fit into a post or page; for example, an “Additional Information” box that appears above the sidebars on a specific page. There are many approaches you could take:
- Code it directly into the template files, which should only be done if the content won’t need to be changed (example: a footer on a website).
- Include it as a custom field on a post or page. This is best for content that is page/post-specific, but found on almost every post or page (example: Photographer’s name associated with the post’s header image).
- Build an additional sidebar. This is best for something that’s repeated often and/or needs to be easily editable.
I’m going to focus on the last approach using additional sidebars.
First you need to create an additional sidebar, then include it somewhere in your site, and finally populate it with content.
Creating an Additional Sidebar
In your functions.php file (or core functionality plugin), include the following code:
That will create a new sidebar titled “Additional Sidebar,” with the appropriate default parameters (which you can change if you like).
Include in Site
Now you can simply drop
dynamic_sidebar( 'additional') directly in your theme somewhere.
Populate the sidebar with content
From your wp-admin area, go to Appearance > Widgets. You should see all of your sidebars displayed on the right side, and your choice of widgets on the left. If you just want text in this sidebar, drag the Text widget over to “Additional Sidebar” and fill it with your title and content. Once you save it, your sidebar should be ready to view on your site.
You can customize the look and feel of it using CSS.
For more information on building sidebars, check out Justin Tadlock’s excellent post Sidebars in WordPress.