• OK, so I need to be able to take a query of posts that list latest posts of a certain category and exclude all but one that are apart of a group of posts with a certain meta value.

    Essentially, I have posts that have a meta key of ul_album_id and value of a random string. If the post is in the same album, they have the same value for that meta_key. I.e. 6 posts with the meta value of 1g8jsk9 for the meta key of ul_album_id.

    What I need in my queried loop is only display one of those 6 in the same album. Make sense?

    Here is my custom query on the page:

    <?php 
    
    $args=array(
        'post_type' => 'post',
        'post_status' => 'publish',
        'paged' => $paged,
        'cat' => $cat,
        'orderby' => $orderby,
        'order' => $order
    );
    
    $my_query = null;
    $my_query = new WP_Query($args);
    while ($my_query->have_posts()) : $my_query->the_post(); ?>
    
    <div class="content-list clearfixit">
    	<ul class="item-wrap clearfixit">
       		<li>....post info, etc.....</li>
        </ul>
    </div>
    
    <?php	endwhile;
    		wp_reset_query();
    ?>

    What I think I need is multiple loops, one to pull the main loop, then a second loop to loop through the posts that have the same meta value and then to skip all the rest in that meta grouping, if you will.

    Any and all help MUCH APPRECIATED! Thanks!

  • The topic ‘Display Only 1 post per Meta Value’ is closed to new replies.