Listing Posts in Multiple Columns
-
I have created a template for a page, and in that page I want to incorporate listing of posts in a category. I have stripped everything out except for just the link itself. I have around 100 posts in this particular category, and I don’t want it to list 100 times down the page. I wanted to list it in, say, 3 columns so it’s organized cleaner. I have tried countless CSS tricks the past couple weeks and haven’t gotten it to work.
I was hoping someone has run into my problem and would have a solution that would work with dynamic content in WP.
This is the example I’m using currently to list the 100 posts down the page (with only one column):
<div class="postarea"> <?php include(TEMPLATEPATH."/breadcrumb.php");?> <!--The blog page template is currently set to show 5 posts. Change showposts=5 to whatever number of posts you want to display.--> <!--Replace cat=1 with the Category ID you want to display in this section. See the README file to learn how to locate the Category ID--> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <h1><?php the_title(); ?></h1> <?php the_content(__('Read more'));?><div style="clear:both;"></div> <?php endwhile; else: ?> <p><?php _e('Sorry, no posts matched your criteria.'); ?></p><?php endif; ?> <ul class="column"> <?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("cat=4&showposts=999&paged=$page"); while ( have_posts() ) : the_post() ?> <li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li> <?php endwhile; ?> </ul> <div style="clear:both;"></div> <p><?php posts_nav_link(); ?></p> </div>
I have tested a ton of CSS tricks but they don’t appear to work. The one I’m currently working with is:
https://www.csscripting.com/css-multi-column/
And that is the CSS class column I’m using (<ul class=”column”>):
ul {margin: 0; padding: 0; list-style: none;} .column { background-color: #fff; border-top: 1px solid #999; border-bottom: 1px solid #999; padding: 8px; } .column { /* the proper rules ready for future */ column-count: 3; column-gap: 5px; column-rule: 1px dotted #999; /* Moz/Firefox rules */ -moz-column-count: 3; -moz-column-gap: 5px; -moz-column-rule: 1px dotted #999; /* Safari & Chrome rules */ -webkit-column-count: 3; -webkit-column-gap: 5px; -webkit-column-rule: 1px solid #999; }
Any help would be greatly appreciated!
- The topic ‘Listing Posts in Multiple Columns’ is closed to new replies.