WordPress.org

Support

Support » Themes and Templates » [Resolved] I want two full-width.php templates in TwentyTwelve

[Resolved] I want two full-width.php templates in TwentyTwelve

  • I want to copy (and rename)full-width.php to use in my TwentyTwelve child theme. No problem, except the copied/renamed template is no longer full width!

    I believe this is because my new template isn’t addressed by this in functions.php

    function twentytwelve_content_width() {
    	if ( is_page_template( 'page-templates/full-width.php' ) || is_attachment() || ! is_active_sidebar( 'sidebar-1' ) ) {
    		global $content_width;
    		$content_width = 960;

    Is there a way to fix this in the child functions.php file?

Viewing 4 replies - 1 through 4 (of 4 total)
  • dragonsjaw
    Participant

    @dragonsjaw

    Wouldn’t you just add another if ( is … statement with the name of your other full width template.

    function twentytwelve_content_width() {
    	if ( is_page_template( 'page-templates/YOUR-TEMPLATE.php' ) || is_attachment() || ! is_active_sidebar( 'sidebar-1' ) ) {
    		global $content_width;
    		$content_width = 960;
    Drew Jaynes
    Docs Czar

    @drewapicture

    Hi geofffox,

    Best-practice in your situation is to duplicate (and rename) the twentytwelve_content_width() function into your child theme’s functions.php file.

    Something along these lines:

    function childtheme_content_width() {
    	if ( is_page_template( 'page-templates/YOURS.php' ) ) {
    		global $content_width;
    		$content_width = 960; //Or whatever width you want
    	}
    }
    add_action( 'template_redirect', 'childtheme_content_width' );

    CambridgeWeb
    Member

    @cambridgeweb

    I also wanted to do this and it sounds really simple but I cannot get the above code to work. Do I need to call this function from within my child theme version of full-width.php? Or is it the template path? Surely a child theme will be just ‘Yours.php’ since it sits in the same directory as the child theme and not a sub directory called page-tamplates, and its not within the twenty-twelve page-templates directory as its a child theme. I tried all of these and even adding a ,11 as last arg into the add_acton Can you suggest anything please?

    Sorry CambridgeWeb, you’ll need to create your own thread for support with your own issues.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] I want two full-width.php templates in TwentyTwelve’ is closed to new replies.