Help With Category Loop + Sidebar

So what I’m trying to do is create a WordPress Loop that displays all posts in a particular category. I’ve done that part and it’s working fine. However, I can’t seem to figure out how to implement a sidebar on the right-hand side.

To be clear, I do NOT want to display the categories or posts in the sidebar itself. I want the posts to be in an 8-column row and I want the sidebar in a 4-column row.

The following code is what I’ve tried, but is not working.

<div class="container" style="min-height: 200px;">
<div class="row">
    <h1><?php the_title() ;?></h1>
<div class="row">
    <!-- the loop -->
    <?php query_posts('cat=5'); ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <div class="col-md-8">
        <?php the_content(); ?>

    <?php endwhile; else: ?>

        <p>Sorry, this page does not exist</p>

    <?php endif; ?>

    <div class="col-md-4">
        <?php get_sidebar('homepage'); ?>

Can anyone tell me where I’m going wrong?

Read more here: Help With Category Loop + Sidebar

Leave a Reply

Your email address will not be published. Required fields are marked *