• Resolved jeff35kl

    (@jeff35kl)


    I am using the TwentyEleven theme with a child theme applied (including a functions.php in my child theme folder). I want to create an exact duplicate of the the ‘Sidebar Template’ page, and name it something else (I want to use different information in the sidebar).

    I copied the ‘sidebar-page.php, renamed it and added the following code to it:
    <?php
    /*
    Template Name: M3-Test
    */
    get_header(); ?>

    The new template showed up in ‘Template’ dropdown in the WordPress dashboard. However, when I applied it to a page, the main content area was as wide as a single column template and it laid on top of the sidebar area. What did I do wrong?

    Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • twenty eleven has a very sophisticated way of dealing with the sidebar;

    at the end of fuctions.php, it adds the css class .singular to the body_class() to mark singular pages; with exemptions for the ‘showcase.php’ and ‘sidebar-page.php’ templates:

    if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) )
    		$classes[] = 'singular';

    you need to compensate this in functions.php of your theme;

    example:
    how to have a new page template with sidebar in a twenty eleven child theme:

    https://pastebin.com/U7zgPTzT

    replace:
    yourtemplatefilename.php
    with the template file name of your new page template

    Thread Starter jeff35kl

    (@jeff35kl)

    Thanks so much for the quick answer, alchymyth. I am relatively new to WordPress and PHP:

    1. Do I paste the code you provided in the functions.php in my child theme folder?

    Do I put another <php> tag around this code?

    Thank you.

    1. Do I paste the code you provided in the functions.php in my child theme folder?

    yes

    Do I put another <php> tag around this code?

    no

    possibly the best place to paste the new code is just before the last ?> in functions.php of the child theme.

    Thread Starter jeff35kl

    (@jeff35kl)

    It worked perfectly, alchymyth. I couldn’t have figured this out myself. Thank you so much for your help. I have an additional question about sidebars, but I will open another string.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Twenty Eleven – Making a new page template from existing page template’ is closed to new replies.