• Resolved alago71

    (@alago71)


    Hi,

    I want to create a full width page template with no sidebar. I use a child theme for twentysixteen.
    I created a folder named “page-templates” in the child’s root and then created a file called “full-width-page-template.php” with the following code:

    <?php
    /**
     * Template Name : Full Width Page
     * 
     *The template for displaying full width pages
     *
     *
     * @package WordPress
     * @subpackage Twenty_Sixteen
     * @since Twenty Sixteen 1.0
     */
    
    get_header(); ?>
    
    <div id="primary" class="full-width-page content-area">
    	<main id="main" class="site-main" role="main">
    		<?php
    		// Start the loop.
    		while ( have_posts() ) : the_post();
    
    			// Include the page content template.
    			get_template_part( 'template-parts/content', 'page' );
    
    			// If comments are open or we have at least one comment, load up the comment template.
    			if ( comments_open() || get_comments_number() ) {
    				comments_template();
    			}
    
    			// End of the loop.
    		endwhile;
    		?>
    
    	</main><!-- .site-main -->
    
    	<?php get_sidebar( 'content-bottom' ); ?>
    
    </div><!-- .content-area -->
    
    <?php /*here there once was the function get sidebar*/?>
    <?php get_footer(); ?>

    and the css related:

    .full-width-page {
    width: 100%;
    }

    Meanwhile, in page edit screen in dashboard, no “Template” dropdown appears in page attributes. Also, in quick edit screen of a page i can only see the “Default template” option in “Template” dropdown.

    Is there a way to make the Template dropdowns visible? If not, can I assign the template to specific pages using some code?

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello @alago71

    First, I don’t know how you did configure your child theme.
    My advise is to remove your actual child theme, install Child Theme Configurator and create a fresh child theme of 2016.
    Then, create directly in the root of your child theme fullwidth.php and paste the following in it.

    <?php
    /**
     * Template Name: FullWidth
     */
    
    get_header(); ?>
    
    <div id="primary" class="content-area" style="width:100%">
    	<main id="main" class="site-main" role="main">
    		<?php
    		// Start the loop.
    		while ( have_posts() ) : the_post();
    
    			// Include the page content template.
    			get_template_part( 'template-parts/content', 'page' );
    
    			// If comments are open or we have at least one comment, load up the comment template.
    			if ( comments_open() || get_comments_number() ) {
    				comments_template();
    			}
    
    			// End of the loop.
    		endwhile;
    		?>
    
    	</main><!-- .site-main -->
    
    	<?php get_sidebar( 'content-bottom' ); ?>
    
    </div><!-- .content-area -->
    
    <?php get_footer(); ?>

    As you can see, I’ve deleted <?php get_sidebar(); ?> and added style=”width:100%” insisde the #primary div of this template.

    SYA ??

    Thread Starter alago71

    (@alago71)

    Fantastic! When I first created the child theme I used the child theme configurator, however it didn’t create an rtl.css file which I need for my site, so I used One click child theme ,an old plugin, to do the job. It did create an rtl.css but made the above problem. Used the configurator and your code and created rtl.css myself and now I’m able to use the custom template.

    Thank you very much @lebcit

    You are most welcome @alago71

    Happy coding ??

    SYA ??

    Hi, Is there a way to get rid of the horizontal scrollbar when using the fullwidth method?

    Hello @chilibird

    When you have an issue, you should create a new support ticket !
    This is not a scrollbar, it’s the boxed style of 2016.

    SYA ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Can’t assign custom full width template to pages’ is closed to new replies.