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.

I searching a lot to found a way solves that and no luck at least.

Sorry for my unpulish english, I do my best explaining my issue.

I have a Custom Post Type called 'Events' this have two categories 'Congresses in Argentina' and 'International Congresses', I need to show the list of posts sorted by columns (2) and with pagination after 5 of each other. Something like this:

Format: Cat 1 / Cat 2 [ 1 = most recent / 5 = oldest post ]

 [1] [1]
 [2] [2]
 [3] [3]
 [4] [4]
 [5] [5]
« 1 2 3 »

I wondering if I can show the last posts of each category on a row and later the next two ones and so on, this because the design needs to be in this way to show up nicely.

Thanks in advance for your help, any comment would be appreciate it.

share|improve this question
    
First: If you write examples, please do it in english. –  kaiser Jan 4 '12 at 17:12
    
And BTW adding comments doesn't push Qs over here :) So just leave it. Doesn't add value and doesn't help you. –  kaiser Jan 4 '12 at 17:20
    
Kaiser, sorry about that, didn't know, this is my first time here and I read this site for a while looking for some advice, next time I'll keep in mind your words. Awaits patiently for a speed up answer :) –  bevi Jan 5 '12 at 12:40
    
Take a look at query_posts and it's args. Then look how to count with php. –  kaiser Jan 5 '12 at 12:53
    
I use two querys one for each custom term of the custom taxonomy and use a custom pagination than do the job, anyways I'm still looking for a way to show the posts of each category on the same row. –  bevi Jan 6 '12 at 2:18
show 6 more comments

2 Answers

Here is the actual code I use to resolve the initial need, this was taken for another question/answer an really works, the only thing I like to make is to put each position of the post of the column at the same row of the other term.

<?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
            ?>

This is a graphical example of what I like to make:

<div class="term-row">
    <div class="col1"><h4>Term 1</h4></div>
    <div class="col2"><h4>Term 2</h4></div>
</div>
<div class="even-row">
    <div class="col1"> // here begins the 1st post of the 1st term
        <?php the_title(); ?>
        <?php the_excerpt(); ?>
    </div>
    <div class="col2"> // here begins the 1st post of the 2nd term
        <?php the_title(); ?>
        <?php the_excerpt(); ?>
    </div>
</div>
<div class="odd-row">
    <div class="col1"> // here begins the 2nd post of the 1st term
        <?php the_title(); ?>
        <?php the_excerpt(); ?>
    </div>
    <div class="col2"> // here begins the 2nd post of the 2nd term
        <?php the_title(); ?>
        <?php the_excerpt(); ?>
    </div>
</div>
<div class="even-row">
    <div class="col1"> // here begins the 3rd post of the 1st term
        <?php the_title(); ?>
        <?php the_excerpt(); ?>
    </div>
    <div class="col2"> // here begins the 3rd post of the 2nd term
        <?php the_title(); ?>
        <?php the_excerpt(); ?>
    </div>
</div>
<div class="pagination">
    <a href="#">Prev</a>
    <span class="current">1</span>
    <a href="#">2</a>
    <a href="#">Next</a>
</div>

Hope its clear enought :)

share|improve this answer
add comment

This is the code I use to make it work, at least it's a start :)

This was for the first column and first term of custom tax:

<ul style="float:left;width:45%;">
<?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts("post_type=evento&categorias-eventos=congresos-en-argentina&showposts=3&paged=$page");
if ( have_posts() ) : while ( have_posts() ) : the_post() ?>
    <li>
        <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>
    </li>
<?php endwhile; endif; ?>

Here begins the second column and second term of the custom tax:

<ul style="float:left;width:45%;">
<?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts("post_type=evento&categorias-eventos=congresos-internacionales&showposts=3&paged=$page");
if ( have_posts() ) : while ( have_posts() ) : the_post() ?>                
    <li>
        <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>
    </li>
<?php endwhile; endif; ?>

And finally the call to a custom pagination function (taken googleing)

<?php if ( function_exists('fb_paging_bar') ) fb_paging_bar(); ?>
share|improve this answer
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.