• Hello, I’ve got a quick question…

    I’ve got a loop that is displaying posts with custom taxonomies….is there a way to only display 1 post from each taxonomy?

    Can anyone help me?

    See my code below:

    <?php
    $args=array(
    //   avoid duplicate posts
    post__not_in => $ids,
    taxonomy => 'session',
    term => 'rhythm-and-roots-2010',
    //   PAGANATION FIX
    paged=>$paged,
    );
    query_posts($args);
    if (have_posts()) :
    echo
    '<div id="mydiv">
    <ul id="mylist">';
    $count = 0;
    while (have_posts()) : the_post();
    $count++;
    echo'<li id=mylist-'.$count.'>';
    $ids[] = get_the_ID();
    ?>
    <span>
    <h2><?php the_title();?></h2>
    <p><?php the_excerpt(); ?></p>
    </span>
    <?php
    echo'</li>';
    endwhile;
    echo '</ul><!– //mylist –></div><!– //mydiv –>';
    endif;
    ?>

Viewing 1 replies (of 1 total)
  • Thread Starter brisimmons105

    (@brisimmons105)

    I’ve updated my code to use wp_query rather than query_posts..
    Still wondering the same question as above….

    A little help?

    <?php
    $args=array(
      'session' => 'rhythm-and-roots-2010',
      'post_status' => 'publish',
      'posts_per_page' => -1,
      'caller_get_posts'=> 1
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      echo 'Artists';
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
        <?php
      endwhile;
    }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>

Viewing 1 replies (of 1 total)
  • The topic ‘Display Only 1 post per custom taxonomy?’ is closed to new replies.