• Resolved ndlunchbox

    (@ndlunchbox)


    I have custom page templates running loops that display lists of posts by category and tag. I used a modified default template from the theme. But for some reason, my sidebar is appearing in the correct place, but the widgets don’t start until below the last line of the main content area.
    Here is my code for one of the page templates (posts by category):
    <?php

    /* template name: Posts by Category */
    get_header(); ?>

    <div id=”primary” class=”content-area>

    <main id=”main” class=”site-main” role=”main”>

    <?php

    $categories = get_categories(‘include=0’);
    foreach ($categories as $category) {
    $cat_id=$category->term_id;
    echo ‘<h2>’ . $category->name . ‘</h2>’;

    $args = array(
    ‘cat’ => $cat_id,
    /*’category__in’ => 0,*/
    ‘order’ => ‘ASC’,
    ‘orderby’ => ‘title’,
    );

    $posts_by_cat = new WP_Query( $args );
    if ($posts_by_cat->have_posts() ) {
    while ( $posts_by_cat->have_posts() ) {
    $posts_by_cat->the_post();
    echo ‘‘.get_the_title().’<br>’;
    }
    }
    }
    wp_reset_postdata();
    ?>

    </main><!– .site-main –>

    <?php get_sidebar( ‘content-bottom’ ); ?>

    </div><!– .content-area –>

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

    • This topic was modified 4 years, 8 months ago by ndlunchbox.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • link to your site?

    what, if any, CSS have you added related to the sidebar?

    without getting the full context of the html and the CSS, there is not much to help.

    Thread Starter ndlunchbox

    (@ndlunchbox)

    I added the test site to the original post, I didn’t modify the CSS from the original theme. Thanks!

    there is a closing quotation mark missing towards the end of this line (corrected below):

    <div id="primary" class="content-area">

    Thread Starter ndlunchbox

    (@ndlunchbox)

    That did it, thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom page template, sidebar appearing below content’ is closed to new replies.