• As the title suggests, I’m trying to create a custom page template, and then call custom widget areas for that page only (by following this tutorial).

    I’ve registered two new sidebars, which are showing in my Appearance – Widgets area. Then I copied the theme’s page.php file and renamed it to new-page.php. This file has been placed in the child theme folder with the following code at the top of the file and before any existing php code.

    <!--?php <br ?--> /*
    Template Name: Blog Page
    */
    ?>

    The page is now visible as an option in Edit Page – Page Attributes – Template, but when I open a page using this template I see the following code visible at the top of the page:

    /* Template Name: Blog Page */ ?>

    I’ve check the Codex, which suggests using the following, but I get the white screen when I try it:

    <?php
    /*
    Template Name: Blog Page
    */

    Any ideas?

Viewing 4 replies - 1 through 4 (of 4 total)
  • can you post the full code of the page template file?

    tha Codex version is the correct way, however, as you have only posted the few lines, it is impossible to check if the error is in what follows after that.

    Thread Starter barnez

    (@pidengmor)

    Thanks for getting back.

    Here is the original page template file for the theme (Motif):

    <?php
    /**
     * The template for displaying all pages.
     *
     * @package Motif
     */
    
    get_header(); ?>
    
    	<div id="primary" class="content-area">
    		<main id="main" class="site-main" role="main">
    
    			<?php while ( have_posts() ) : the_post(); ?>
    
    				<?php get_template_part( 'content', 'page' ); ?>
    
    				<?php
    					// If comments are open or we have at least one comment, load up the comment template
    					if ( comments_open() || '0' != get_comments_number() )
    						comments_template();
    				?>
    
    			<?php endwhile; // end of the loop. ?>
    
    		</main><!-- #main -->
    	</div><!-- #primary -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    the code looks ok – does that template give you any errors?

    what is the code of your page template ‘Blog Page’?

    try and enable DEBUG to see if you get any error messages with the ‘white screen’; https://codex.www.ads-software.com/Debugging_in_WordPress

    what theme are you working with?

    Thread Starter barnez

    (@pidengmor)

    The theme is the Motif Theme (self-hosted).

    Using the unedited page template and debug set to on gives 8 errors related to a form calculator plugin. As these are present on the other pages using the theme’s other templates, I would think they are unrelated to this issue (I’ll put them on the “to do list” for now)

    When I add the following code to the top of the file

    <!--?php <br ?--> /*
    Template Name: Widgetized Page
    */
    ?>

    all the plugin error messages remain, plus /* Template Name: Widgetized Page */ ?> below them.

    When I instead add the WordPress Codex code to the top of file:

    <?php
    /*
    Template Name: Blog Page
    */

    I see an additional php error:

    Parse error: syntax error, unexpected '<' in /home/englis01/public_html/test/wp-content/themes/motif-child/new-page.php on line 6

    By replacing the existing

    <?php
    /**
     * The template for displaying all pages.
     *
     * @package Motif
     */

    with the code from the Codex, all is well. I think should chalk this down to novice php pilot error ??

    Many thanks for your help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom page template and widegetized sidebar’ is closed to new replies.