geofffox
Member
Posted 6 months ago #
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?
dragonsjaw
Member
Posted 6 months ago #
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;
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
Posted 5 months ago #
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.