SIdebar not displaying on side

Hello, I’m creating a newspaper website and I need the homepage to display recent posts from a variety of categories in a specific way so I created a custom template.

I just got started on it and trying to figure out why my sidebar is not actually on the side. It’s displayed below the posts. What did I do wrong?

THank you!
Rena

<?php
/*
Template Name: Snarfer
*/
?>


<?php




get_header();

?>
 
<div class="x-container max width main">
    <div class="offset cf">
      <div class="<?php x_main_content_class(); ?>" role="main">
  
      

  <div class="customCat"    <?php $catquery = new WP_Query( 'cat=65&posts_per_page=5' ); ?>
<ul style="list-style-type:none;">
<?php while($catquery->have_posts()) : $catquery->the_post(); ?>
<li><h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
By <?php the_author_posts_link(); ?> | <?php the_time('F jS, Y'); ?>  <?php edit_post_link(__('{Edit}'), ''); ?>
<?php the_post_thumbnail(); ?>
<ul style="list-style-type:none;"><li><?php the_excerpt(); ?></li>

</ul>
</li>
<?php endwhile; ?> 
</ul>

<?php wp_reset_postdata(); ?>
    </div>  
      
      
      

      <?php get_sidebar(); ?>

    </div>
  </div>
</div>
<?php get_footer(); ?>

Hello Rena,

Thanks for writing in!

We highly recommend that you doing your customization, always indent your code so that you can properly see the opening and closing of each statements and lines. Take this code for example:

<?php
/*
Template Name: Snarfer
*/
?>


<?php get_header(); ?>
 
<div class="x-container max width main">
    <div class="offset cf">
      <div class="<?php x_main_content_class(); ?>" role="main">
  
        <?php $catquery = new WP_Query( 'cat=65&posts_per_page=5' ); ?>

        <div class="customCat"> 
        <ul style="list-style-type:none;">
            <?php while($catquery->have_posts()) : $catquery->the_post(); ?>
              <li>
                <h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
                By <?php the_author_posts_link(); ?> | <?php the_time('F jS, Y'); ?>  
                <?php edit_post_link(__('Edit'), ''); ?>
                <?php the_post_thumbnail(); ?>
                <ul style="list-style-type:none;">
                  <li><?php the_excerpt(); ?></li>
                </ul>

              </li>
            <?php endwhile; ?> 
        </ul>

        <?php wp_reset_postdata(); ?>
        </div>  
      
      </div>  
      

      <?php get_sidebar(); ?>


  </div>
</div>
<?php get_footer(); ?>

It is more neat and clean. Everything were line up and it is easy to see if the <div> tags were properly closed with </div> or not because that is what is happening in your site right now.

Hope this helps.

Ohh rookie mistake. Thank you!

You’re most welcome!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.