Sidebar Support for the Twenty Eleven Theme

WordPress

due to one of my „customers“ needs the WordPress Theme Twenty Eleven with Sidebar enabled I found the following solution, which is mainly based on the articel of Chris Aprea.

the recommended method of making changes to a WordPress Theme is by creating a child theme.

let’s start with the stylesheet for the theme.

/*
Theme Name:     Twenty Eleven Child w/ Sidebar Support
Theme URI:      //blog.kmp.or.at/?p=313
Description:    Child theme for the Twenty Eleven which includes
                support for sidebars everywhere
Author:         Klaus Maria Pfeiffer, Chris Aprea
Template:       twentyeleven
Version:        1.2
*/

/* We must first include the original css from the parent theme */
@import url("../twentyeleven/style.css");

.jp-carousel-image-meta {
  display: none;
}

in lines 13 – 15 the Image Meta Data for the WordPress JetPack Carousel is disabled.

in functions.php remove the filter that adds the singular class to the body element …

<?php

// In child themes the functions.php is applied before the parent
// theme's functions.php. So we need to wait for the parent theme
// to add it's filter before we can remove it.
add_action( 'after_setup_theme', 'my_child_theme_setup' );

function my_child_theme_setup() {
  // Removes the filter that adds the "singular" class to the body
  // element which centers the content and does not allow for a
  // sidebar
  remove_filter( 'body_class', 'twentyeleven_body_classes' );
}

?>

due to the request was to have the sidebar on every page, I just add the function get_sidebar() to the themes page.php (means, just copy it from the Twenty Eleven Theme and modify it accordingly).

<?php
/**
 * The template for displaying all pages.
 *
 * This is the template that displays all pages by default.
 * Please note that this is the WordPress construct of pages
 * and that other 'pages' on your WordPress site will use a
 * different template.
 *
 * @package WordPress
 * @subpackage Twenty_Eleven
 * @since Twenty Eleven 1.0
 */

get_header(); ?>

		<div id="primary">
			<div id="content" role="main">

				<?php while ( have_posts() ) : the_post(); ?>

					<?php get_template_part( 'content', 'page' ); ?>

					<?php comments_template( '', true ); ?>

				<?php endwhile; // end of the loop. ?>

			</div><!-- #content -->
		</div><!-- #primary -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

that’s it. you also can download this child theme.

1 Kommentare

  1. Thanks – I don´t get the difference between the original child theme (by Chris Aprea) and yours? What is your advantage?
    Deutsche Antwort auch OK 🙂

Kommentare sind geschlossen.