Support » Fixing WordPress » Split archive results in rows and columns

  • Resolved pustiu314p


    Hi, I want to redesign my Archives template, so I want do display posts from archive in 3 columns and 6 rows. I have the following code:

    <?php get_header(); ?>
    	<?php include(TEMPLATEPATH. '/includes/templates/sidebar-left.php'); ?>
    	<div id="content-wrap">
    	<div id="content-arhiva" class="list-content">
    			include(TEMPLATEPATH. '/includes/templates/heading.php');?>
    <table width="100%" border="0" cellpadding="4" cellspacing="3" bgcolor="#CCB294">
    <tr align="left" valign="top">
    <td class="rndCorners">
    			if (have_posts()) {
    				while (have_posts()) : the_post();
    				global $post;
    					include(TEMPLATEPATH. '/includes/templates/loop.php');
    			} else {
    				include(TEMPLATEPATH. '/includes/not-found.php');
    <?php if ( $wp_query->max_num_pages > 1 ) tj_pagenavi();
    	</div><!-- #content -->
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    but the code is displaying in one row and many moore columns. How can I force the yo display as I wwant? Thank you.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Here is an article with sample code that may help:

    Align Posts in a Row, aka Posts in Columns

    well that seems to not work for me 🙁 any other idea?

    The code I gave is only an example. You probably cannot just copy/paste it into your template, the important thing is the concept of using a counter to create rows and post cells. I have updated the article to indicate this.

    You should create a template to display the posts one after the other (the normal way), and then add in the code for the counter and the post_class div. Then add CSS rules to set their widths.

    my problem is not CSS, I do not know how to integrate `$posts_per_row = 5;
    $posts_per_page = 20;` and any other neccerary things to make my code to split results.

    Hi again, I finally managed and thanks a lot, but now I have another problem, even if you are in a certain category are displayed all items from all categories.

    The first step is to create a template that will display the posts you want, but one after another, not in rows. Then add in the code to create the rows.

    I managed to filter results by category. The problem was query_posts($args); I changed that with rewind_posts(); but now $posts_per_page = 20; is no longer relevant, if I would give any value only displays 10 results.



    Forum Moderator

    please post the latest code of your template
    – please use the pastebin –

    can you post a link to your site to illustrate the output of your code?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Split archive results in rows and columns’ is closed to new replies.