WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Split archive results in rows and columns (9 posts)

  1. pustiu314p
    Member
    Posted 1 year ago #

    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">
    
    <?php
    			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">
    
    	<?php 
    
    			rewind_posts();
    			if (have_posts()) {
    				while (have_posts()) : the_post();
    				global $post;
    					include(TEMPLATEPATH. '/includes/templates/loop.php');
    					$postcount++;
    				endwhile;
    			} else {
    				include(TEMPLATEPATH. '/includes/not-found.php');
    			}
    
    		?>
    
    </td></tr></table>
    
    <?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.

  2. vtxyzzy
    Member
    Posted 1 year ago #

    Here is an article with sample code that may help:
    http://wordpress.mcdspot.com/2010/11/28/align-posts-in-a-row/

  3. pustiu314p
    Member
    Posted 1 year ago #

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

  4. vtxyzzy
    Member
    Posted 1 year ago #

    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.

  5. pustiu314p
    Member
    Posted 1 year ago #

    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.

  6. pustiu314p
    Member
    Posted 1 year ago #

    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.

  7. vtxyzzy
    Member
    Posted 1 year ago #

    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.

  8. pustiu314p
    Member
    Posted 1 year ago #

    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.

  9. alchymyth
    Forum Moderator
    Posted 1 year ago #

    please post the latest code of your template
    - please use the pastebin - http://codex.wordpress.org/Forum_Welcome#Posting_Code

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

Topic Closed

This topic has been closed to new replies.

About this Topic