Skip to Content
WordPress® All-in-One For Dummies®
book

WordPress® All-in-One For Dummies®

by Lisa Sabin-Wilson, Cory Miller, Kevin Palmer, Andrea Rennick, Michael Torbert
April 2011
Beginner to intermediate content levelBeginner to intermediate
908 pages
22h 37m
English
For Dummies
Content preview from WordPress® All-in-One For Dummies®

Using Sidebar Templates

You can create separate sidebar templates for different pages of your site by using a simple include statement. When you write an include statement, you're simply telling WordPress that you want it to include a specific file on a specific page.

The code that pulls the usual Sidebar template (sidebar.php) into all the other templates, such as the Main Index template (index.php), looks like this:

<?php get_sidebar(); ?>

What if you create a page and want to use a sidebar that has different information from what you have in the Sidebar template (sidebar.php)? Follow these steps:

  1. Create a new sidebar template in a text editor such as Notepad.

    See Book VI for information on template tags and themes.

  2. Save the file as sidebar2.php.

    In Notepad, choose FileimageSave. When you're asked to name the file, type sidebar2.php, and then click Save.

  3. Upload sidebar2.php to your Themes folder on your Web server.

    See Book II, Chapter 2 for FTP information, and review Book VI for information on how to locate the Themes folder.

    The template is now in your list of theme files on the Edit Themes page (log in to your WordPress Dashboard and click Editor in the Appearance drop-down list).

  4. To include the sidebar2.php template in one of your page templates, replace the code:

    <?php get_sidebar(); /> with the code <?php get_template_part(‘sidebar2’); ?> (which calls in a template you've ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

WordPress® 24-Hour Trainer

WordPress® 24-Hour Trainer

George Plumley
Gaming Hacks

Gaming Hacks

Simon Carless

Publisher Resources

ISBN: 9780470877012Purchase book