Add Sidebar to front-page template in Sydney theme

Hey,
Can you help me to add a sidebar to the front-page template in Sydney Theme as I do not want to use the default template for it which has the sidebar.
I already have the Sydney Child Theme installed

Hello there,

Instead of editing the existing front page template, it would be a lot easier if we could create a new page template and reproduce the front page template’s styles onto it. Try doing the below steps:

  1. In your child theme folder, create a new folder and name it as “page-templates” (without quotes);
  2. Inside this new folder, add a new file page_front-page-with-sidebar.php
  3. Paste this code into it
<?php
/*
Template Name: Front Page with Sidebar
*/

get_header(); ?>

<div id="primary" class="content-area col-md-9">
  <main id="main" class="post-wrap" 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() || get_comments_number() ) :
          comments_template();
        endif;
      ?>

    <?php endwhile; // end of the loop. ?>

  </main><!-- #main -->
</div><!-- #primary -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

In your child theme you’ll have page-templates/page_front-page-with-sidebar.php.

48%20AM

  1. To replicate front page template’s style to your new created page template, add this code to your child theme functions.php
add_filter( 'body_class', 'sydney_child_body_class' );
function sydney_child_body_class($classes) {

  if( is_page_template('page-templates/page_front-page-with-sidebar.php') ) {
    $classes[] = 'page-template-page_front-page';
  }

  return $classes;

}
  1. Upload the changes over FTP or cPanel;
  2. Edit your page; in the Page Attributes box, select Front Page with Sidebar template.

17%20AM

Regards,
Kharis

Thanks a lot Kharis!!!
Worked perfectly!

You’re welcome!

Please let us know in a new topic if you have any further questions, or if we can provide you with any other assistance.

Regards,
Kharis