Custom page template, sidebar appearing below content
-
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(); ?>The page I need help with: [log in to see the link]
- The topic ‘Custom page template, sidebar appearing below content’ is closed to new replies.