• Resolved Hallofthemtking

    (@hallofthemtking)


    How can I remove the sidebar from Pages but not from the static page? In other words, create a full width page.

    Thanks

Viewing 1 replies (of 1 total)
  • You can create a Page Template for this purpose, create a new file called template-full.php and place it within your Child Theme folder.

    Add this to the template-full.php file:

    <?php
    /* Template Name: Full Width */
    get_header(); ?>
    <div id="primary" class="content-area">
        <main id="main" class="site-main athena-page" role="main"><?php 
            while (have_posts()) : the_post(); 
                get_template_part('template-parts/content', 'page-full'); 
                if (comments_open() || get_comments_number()) :
                    comments_template();
                endif; 
            endwhile; ?>
        </main> 
    </div><?php 
    get_footer(); ?>

    Create a sub-folder within your child theme folder called template-parts, and create a new file inside it called content-page-full.php.

    Add this to the content-page-full.php file:

    <?php if (get_post_thumbnail_id($post->ID)) : ?>
        <div id="athena-page-jumbotron" class="parallax-window" data-parallax="scroll" data-image-src="<?php echo wp_get_attachment_url(get_post_thumbnail_id($post->ID)) ?>">
            <header class="entry-header"><?php 
                the_title('<h1 class="entry-title">', '</h1>'); ?>
            </header>
        </div><?php 
    endif; ?>
    <div class="row">
        <div class="col-sm-12">
            <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                <div class="entry-content"><?php 
                    if (!get_post_thumbnail_id($post->ID)) : ?>
                        <header class="entry-header"><?php 
                            the_title('<h1 class="entry-title">', '</h1>'); ?>
                        </header><?php 
                    endif;
                    the_content(); 
                    wp_link_pages(array('before' => '<div class="page-links">' . esc_html__('Pages:', 'athena'),'after' => '</div>',)); ?>
                </div>
                <footer class="entry-footer"><?php
                    edit_post_link(sprintf(esc_html__('Edit %s', 'athena'), the_title('<span class="screen-reader-text">"', '"</span>', false)), '<span class="edit-link">', '</span>'); ?>
                </footer>
            </article>
        </div>
    </div>

    You can now edit a page and assign the new page template you’ve just created to it, it should display full-width with no sidebars.

    All of the above code has been taken from the existing theme files with very minor modifications to load a different content file and to remove the sidebars.

    Hope this helps.

Viewing 1 replies (of 1 total)
  • The topic ‘Remove side Bar from specific pages’ is closed to new replies.