Support » Fixing WordPress » Full-width Page Template, No Sidebar Page Template

  • The ‘Full-width Page Template, No Sidebar Page Template’ for Twenty Twelve; what part of it is what notes that the page will be full-width without the sidebar? I understand how to remove the sidebar, but trying to figure out how to make another custom template full-width as well when the sidebar is removed.

Viewing 9 replies - 1 through 9 (of 9 total)
  • start by creating a child theme;

    look into functions.php of the Twenty Twelve – there is a section which regulates the body_class() output according to the page templates….

    replicate that in your child theme.

    I believe I found the spot. In the WordPress codex I read that when creating functions.php it adds to the functions.php of the parent theme. This is the first time I am adding to that file though and what I tried to do is copy that whole function over it had a heart-attack and I knew I did something wrong so I reversed it. It said I couldn’t redeclare the function, fair enough, but then how do I add to it or edit part of it in the child theme? Sorry to be going off-topic for a moment.

    how do I add to it or edit part of it in the child theme?

    create a new function with a different name;

    for example:

    add_filter( 'body_class', 'twentytwelvechild_body_class', 15 );
    function twentytwelvechild_body_class( $classes ) {
    	if ( is_page_template( 'your_custom_full_width_template_file_name.php' ) )
    		$classes[] = 'full-width';

    the 15 is added as priority to execute that filter after the parent theme’s filter.

    Thank you so much for your feedback and links to codex so I understand the code you are posting, specifically the filter part because I would’ve just added the function part and wonder why it’s not working.

    Problem is tho, I am getting a PHP Error:

    Warning: join() [function.join]: Invalid arguments passed in /public_html/wp-includes/post-template.php on line 389

    Not sure why that is.

    my mistake – I copied this partially from my test site and forgot the ‘return $classes;’ line;


    add_filter( 'body_class', 'twentytwelvechild_body_class', 15 );
    function twentytwelvechild_body_class( $classes ) {
    	if ( is_page_template( 'your_custom_full_width_template_file_name.php' ) )
    		$classes[] = 'full-width';
    return $classes;

    The sidebar came back! Haha that doesn’t even seem to make sense. It is using the same if-statement as the template with no sidebar and I removed the sidebar include from the bottom of my template! So weird.

    can you post the full code of your page template?
    and the code used in functions.php?

    does the page still use the page template?

    The page uses a Page-of-Posts Template I found here:

    Page-Of-Posts Template for Twenty Twelve

    And with your help in another post I made a small change so that the posts show excerpts. Here is the full code for the template:

     * Template Name: Page of Posts
     * for a child theme of Twenty_Twelve
    get_header(); ?>
            <div id="primary" class="site-content">
                    <div id="content" role="main">
                            $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
                            $args= array(
                                    'category_name' => 'Uncategorized', // Change this category SLUG to suit your use; or see for query parameters
                                    'paged' => $paged,
            'posts_per_page' => 3,
            'post_type' => 'post',
                            if( have_posts() ) : ?>
                      <?php while ( have_posts() ) : the_post(); ?>
                           <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                <header class="entry-header">
                  <h1 class="entry-title">
                    <a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
                  <?php the_post_thumbnail(); ?>
                </header><!-- .entry-header -->
                <div class="entry-summary">
                  <?php the_excerpt(); ?>
                </div><!-- .entry-summary -->
                <footer class="entry-meta">
                  <?php twentytwelve_entry_meta(); ?>
                  <?php edit_post_link( __( 'Edit', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?>
                </footer><!-- .entry-meta -->
      </article><!-- #post -->
                            <?php comments_template( '', true ); ?>
                          <?php endwhile; // end of the loop. ?>
                          <?php twentytwelve_content_nav( 'nav-below' ); ?>
                    <?php else : ?>
                      <article id="post-0" class="post no-results not-found">
                          <header class="entry-header">
                                <h1 class="entry-title"><?php _e( 'Nothing Found', 'twentytwelve' ); ?></h1>
                          <div class="entry-content">
                                <p><?php _e( 'Apologies, but no results were found. Perhaps searching will help find a related post.', 'twentytwelve' ); ?></p>
                                <?php get_search_form(); ?>
                          </div><!-- .entry-content -->
                      </article><!-- #post-0 -->
                    <?php endif; wp_reset_query(); ?>
            </div><!-- #content -->
        </div><!-- #primary -->

    And here is the code currently in my functions.php of my child theme:

    add_filter( 'body_class', 'twentytwelvechild_body_class', 15 );
    function twentytwelvechild_body_class( $classes ) {
    	if ( is_page_template( 'homeTemplate.php' ) )
    		$classes[] = 'full-width';
    return $classes;
    function my_theme_thumb() {
    set_post_thumbnail_size( 150, 150, true );
    add_action( 'after_setup_theme', 'my_theme_thumb', 11 );

    Well, I’m not sure what changed but it seems to be working now. The only thing is is just on that page the lil WordPress header thing at the top that links to the Dashboard and all that is missing and on all my pages is a title link of my site located above the Navigation (which is still above the header logo by default), and I am not sure why but I’ll look into that.

    I might have confused it with my “blog” page that is normal, as I recently swapped the two and made my customized one the “home” page so I apologize about that. Thank you so much though for all your help!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Full-width Page Template, No Sidebar Page Template’ is closed to new replies.