WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] New Template Breaks (3 posts)

  1. dorich
    Member
    Posted 2 years ago #

    Theme: twentyeleven
    New Templates are located in the child theme.
    Attempted to create a new template by using the following copied from index.php

    <?php get_header(); ?>
    
        <div id="primary">
            <div id="content" role="main">
    
                         html content
                       </div>
                </div>
     <?php get_sidebar();?>
     <?php get_footer(); ?>

    This code breaks because the outmost div expands to 100% width and pushes the sidebar down. The original index.php page displays as expected with the sidebar in the correct position.

    Looking the style.css (the original, not the child theme file) it appears there are several rules for #primary, thus:
    Rule 1

    #primary {
    float: left;
    margin: 0 -26.4% 0 0;
    width: 100%;
     }

    Rule 2

    #primary {
        float: left;
        margin: 0;
        width: 100%;
    }

    Rule 3

    .singular #primary {
    margin: 0;
    }

    It appears that rule 3 is activated and is overriding Rule 1. The reason that rule 3 is activated appears to be that ".singular" appears as a class in the body tag.
    Now I'm puzzled. How does the .singular class get applied? Something to do with the following I suppose:
    <body <?php body_class($class); ?>>

    but what prompts this action and why does it happen.
    All I want is a template that will display custom taxonomy terms and maintain a sidebar on the RHS.
    Any suggestions as to another approach or a way to unravel this one. I thought that index.php would be the right template to copy from but it seems there is more to it than that. Note I realize that I could do something like replacing the div's with my own and my own css but I would have thought that is something that should be easily done with WP "as is".
    Currently the problem can be seen at book dot value-based-marketing dot com/table-of-contents
    Thanks

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

    if this is a page template, you are talking about, then my article might be related.

    The reason that rule 3 is activated appears to be that ".singular" appears as a class in the body tag.
    Now I'm puzzled. How does the .singular class get applied? Something to do with the following I suppose:
    <body <?php body_class($class); ?>>

    have a look into functions.php of Twenty Eleven - near the end.

  3. dorich
    Member
    Posted 2 years ago #

    @alchymyth

    Thanks. I didn't know where to look. Now I understand what is going on.

Topic Closed

This topic has been closed to new replies.

About this Topic