Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Let me explain better, I have two categories and I want to show a page with two columns one for each category, after this I like to show in the same row each post of each category on each column, just to apply the same background color independently of the length of the text.

What is the easy and right way to do some like that?

Thanks in advance, Regards!

Edit: add the queries I use.

<?php
            // for a given post type, return all
            $post_type = 'evento';
            $tax = 'categorias-eventos';
            $tax_terms = get_terms($tax);
            $post_counter = 0; // reset so we can generate columns 
            $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

                if ($tax_terms) { ?>

                <ul class="column_wrap" style="width:45%; float:left;">         
                <?php foreach ($tax_terms as $tax_term) {
                     $args = array(
                    'post_type' => $post_type,
                    "$tax" => $tax_term->slug,
                    'post_status' => 'publish',
                    'posts_per_page' => 6,
                  //'posts_per_page' => -1,
                  //'paged' => $paged,
                    'orderby' => 'title',
                    'order' => 'ASC',
                    'caller_get_posts' => 1
                    ); // END $args

                    $my_query = null; // clear the query variable
                    $my_query = new WP_Query($args);

                    if( $my_query->have_posts() ) { ?>

                      <li class="column_row" style="float:left;">
                        <h4><?php echo $tax_term->name; ?></h4>
                      </li>

                        <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
                        <li class="column_row" style="float:left;">
                            <div class="retailer_wrap retailer_id-<?php the_ID(); ?>">
                                <p><strong><?php the_title(); ?></strong></p>
                                <p><?php echo get_post_meta($post->ID, 'eventdate', true);?></p>
                                <p><?php echo get_post_meta($post->ID, 'eventplace', true);?></p>
                            </div>                                  
                        </li>
                        <?php $post_counter++; ?>

                        <?php if ( 0 == $post_counter % 6 ) { ?>
                  </ul>                          
                  <ul class="column_wrap noneed" style="width:45%; float:left;">
                <?php } // END if $post_counter ?>
              <?php
              endwhile;
              //wp_pagenavi( array( 'query' => $my_query ) ); 
            } // END if have_posts loop
            wp_reset_query();

          } // END foreach $tax_terms ?>
          </ul>
        <?php } // END if $tax_terms
        ?>

Edit 2: add the image of the final result I want to approach.

Two columns of two categories, each post of each category respect the same row height, how to do this?

Like I don't have enough permission to post an image this is the link to the image. enter link description here

share|improve this question
    
    
Hi Michael, I create this post with different answer trying to explain me better, at the time was right I put the code. Don't understand why you rep me negative if I use different ways to clear my question. On the other post don't have too much attention and let it forgotten, don't really know if I must delete those ones, please sorry if I break some laws here. –  bevi Jan 19 '12 at 13:44
add comment

1 Answer

Assuming you've already got your HTML/CSS whipped up, you will need two separate custom queries. Here's one, a here is documentation.

// Custom Query parameters. This one grabs most recent 5 posts from category with ID 9
// For each loop, change "$the_query" variable to something unique
$the_query = new WP_Query( 'cat=9&posts_per_page=5' );
// Begin Custom Loop
while ( $the_query->have_posts() ) : $the_query->the_post();
    // Regular loop stuffs
    echo '<li>';
    the_title();
    echo '</li>';
endwhile;

// Reset Post Data - important for multiple loops on the same page. Should follow each loop.
wp_reset_postdata();
share|improve this answer
    
Steph thank for your response, I have my html/css whipped up like you said, if I use two separate custom queries every post listed on each column/category doesn't respect the same row of the other column, beside this after 6 posts listed on any column I want to use pagination, can you help me on this? –  bevi Jan 18 '12 at 20:47
    
Since you're new to the site - don't forgot to mark this as the answer if it works for ya, thanks! –  5t3ph Jan 18 '12 at 20:50
    
Oh I submitted my comment before your edit... Do you mean your post titles cause them to be misaligned? The best way I know of is to define a height for the <li>. As for pagination, I'm not sure how to make it work for individual queries. That would be worth posting a new question just for that portion. –  5t3ph Jan 18 '12 at 20:53
    
On the initial answer I add the code I use, there you can see than for one category the posts goes on one column and if there is another category goes on other column, if are more than 6 posts pagination appears, I add an image than shows what I want. –  bevi Jan 18 '12 at 23:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.