WordPress.org

Ready to get started?Download WordPress

Forums

Twenty Eleven Custom Template Issue (2 posts)

  1. joe1977
    Member
    Posted 1 year ago #

    Have you created a custom page template for Twenty Eleven?

    Did you copy an existing template and just changed the template name, yet it renders completely different and you don't know why?

    The solution is you need to add that new template file to the Body Classes in the functions.php file.

    Open the functions.php file and go to the end, about line 583 to find :

    [please mark any posted code - http://codex.wordpress.org/Forum_Welcome#Posting_Code ]

    function twentyeleven_body_classes( $classes ) {
    
    	if ( function_exists( 'is_multi_author' ) && ! is_multi_author() )
    		$classes[] = 'single-author';
    
    	if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) )
    		$classes[] = 'singular';
    
    	return $classes;
    }
    add_filter( 'body_class', 'twentyeleven_body_classes' );

    You need to add your custom template file name after the side bar page so it looks like this:

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

    I hope this is helpful, because the info CANNOT BE FOUND IN THE DOCUMENTATION FOR THE DEFAULT WORDPRESS THEME!!!

    This is the second time I've run across an issue related to the default theme that is not found in any documentation. WORDPRESS - update the documentation.

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    CANNOT BE FOUND IN THE DOCUMENTATION FOR THE DEFAULT WORDPRESS THEME

    I am not aware that such documentation exists - can you post a link to this documentation - even if it is not complete?

    if you are working with a child theme of Twenty Eleven - as recommended - you need to make the correction in functions.php of the child theme; see for instance http://www.transformationpowertools.com/wordpress/twenty-eleven-new-page-template-with-sidebar-correction

Topic Closed

This topic has been closed to new replies.

About this Topic