WordPress.org

Ready to get started?Download WordPress

Forums

How to add sidebar to Twenty Eleven child theme pages (6 posts)

  1. befree22
    Member
    Posted 2 years ago #

    I'm using a 2011 child theme where the homepage is unique and other pages don't display the sidebar except the Blog page on prosocialroi.com.

    Where do I add the following code so that I can include the sidebar?

    <?php get_sidebar(); ?>

    I know that you can't modify parent WordPress pages. My 2011 child theme doesn't have a page.php file and I want to add the sidebar to the child theme page.php. The 2011 child theme I'm using on prosocialroi.com doesn't include the sidebar. Here's the code for the parent 2011 page.php http://pastebin.com/S78nb3wN
    I tried adding the parent page.php to the child theme's pages but the sidebar is displaying below the content area, not on the side -- see http://www.prosocialroi.com/contact-us

    Also, I want to add the sidebar to information.php pages see http://pastebin.com/eLwZ90k5. I'm unsure which file needs modifying to check website with Firebug to ensure that information.php is the file that needs modifying.

  2. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    you can use the 'Sidebar Template' for static pages with sidebar.

    for general ideas how to get a sidebar to pages and single posts, see for instance my post. there is also a link to a possible plugin to help with what you are trying to do.

  3. befree22
    Member
    Posted 2 years ago #

    Hi alchymth,

    It works! I read http://www.transformationpowertools.com/wordpress/twenty-eleven-sidebar-on-single-posts-and-pages and added the code to the page.php file that I copied from the parent twenty eleven theme into the child theme.

    My child theme doesn't have a single.php page either. I decided to leave out the code in the PS: A Few Different Cases section because I'm unclear about the page template to modify. I looked for the following code in the sidebar-page.php, single.php and the page.php (the only one I copied into my child theme) but it's not there...

    if( is_single() || is_page() ) :

  4. befree22
    Member
    Posted 2 years ago #

    Hi alchymth,

    I just saw the following code in the filter that I added to functions.php

    if( is_single() || is_page() ) :

    Your tutorial states that: "if you rather use the sidebar-page template that comes with the theme, to control if and when to show a sidebar on a static page, simply don’t edit page.php, and remove"

    || is_page()

    I would like the option to control whether or not the sidebar appears on a page or post. Neither the page.php which I added to my child theme, nor the sidebar-page.php, single.php have this code

    if( is_single() || is_page() ) :

    If I want to control whether or not the sidebar appears on a page or post, couldn't I simply replace if( is_single() || is_page() ) :
    with if( is_single() ) : code?

  5. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    this code if( is_single() || is_page() ) : is part of the added filter code for functions.php -

    add_filter('body_class', 'blacklist_body_class', 20, 2);
    function blacklist_body_class($wp_classes, $extra_classes) {
    if( is_single() || is_page() ) :
    // List of the classes to
    ...

    If I want to control whether or not the sidebar appears on a page or post, couldn't I simply replace ...

    yes

  6. befree22
    Member
    Posted 2 years ago #

    Hi alchymth,

    Since this code if( is_single() || is_page() ) : is in the functions.php, and this code in the functions.php controls sidebar calls for all pages, how do I "tell" the functions.php to not show the sidebar or an specific page, ex. prosocial.com/contact-us ?

    I know that to prevent the sidebar from displaying on prosocial.com/contact-us I have to add this code
    if( is_single() ) : to the functions.php but how do I indicate that using code?

Topic Closed

This topic has been closed to new replies.

About this Topic