Yet another “pageofposts” sidebar wandering off problem
-
I bet you’re all sick of sidebars going walkabout in conjunction with the pageofposts template, however, I’ve got one myself.
Here’s the deal;
See here – https://www.buryandramsbottomartweek.co.uk/news/
If there is only one post to the news page, the sidebar stays in place on the right.If there are two posts, seemingly regardless of the length of the post, the sidebar drops to below the last post on the page and I can’t figure out why.
If like so many other people, the sidebar was always below the last post, I could understand it.
But to do it when there is more than one post on the page, is confusing the hell out of me..!Can anybody shed some light?
Here’s the pageofposts code;
<?php /* Template Name: PageOfPosts */ get_header(); ?> <?php // page id 21 will get category ID 12 posts, page 16 will get category 32 posts, page 28 will get category 17 posts //page: 51-news (cat-5), 13-events (cat-3), 15-featured artists (cat-4), 61-venues (cat-6), 140-delivery and collection (cat-7) if (is_page('51') ) { $cat = array(5); } elseif ( is_page('13') ) { $cat = array(3); } elseif ( is_page('15') ) { $cat = array(4); } elseif ( is_page('61') ) { $cat = array(6); } elseif ( is_page('140') ) { $cat = array(7); } else { $cat = ''; } $showposts = -1; // -1 shows all posts $do_not_show_stickies = 0; // 0 to show stickies $args=array( 'category__in' => $cat, 'showposts' => $showposts, 'caller_get_posts' => $do_not_show_stickies ); $my_query = new WP_Query($args); ?> <div id="main"> <?php if ( $my_query->have_posts() ) : while ($my_query->have_posts()) : $my_query->the_post();; ?> <?php //necessary to show the tags global $wp_query; $wp_query->in_the_loop = true; ?> <div <?php post_class() ?> id="post-<?php the_ID(); ?>"> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <p class="post-info">Posted by <?php the_author() ?> | Filed under <?php the_category(', ') ?></p> <?php the_content(); ?> <p class="post-footer"> <?php the_tags('Tags: ', ', ', '<br />'); ?> <a href="<?php the_permalink() ?>" class="readmore">Read more</a> | <a href="<?php comments_link(); ?>" class="comments">Comments (<?php comments_number('0','1','%'); ?>)</a> | <span class="date"><?php the_time('M j, Y') ?></span> </p> <?php endwhile; ?> <div class="float-left"><?php next_posts_link('« Older Entries') ?></div> <div class="float-right"><?php previous_posts_link('Newer Entries »') ?></div> <?php else : ?> <h2>Not Found</h2> <p>Sorry, but you are looking for something that isn't here.</p> <?php endif; ?> <!-- main ends --> </div> </div> <?php get_sidebar(); ?> <?php get_footer(); ?>
- The topic ‘Yet another “pageofposts” sidebar wandering off problem’ is closed to new replies.