phpchick Posted December 22, 2010 Share Posted December 22, 2010 <?php query_posts('showposts=10'); ?> <!-- The 10 most recent post, the first one not included --> <h2>Other Recent Articles</h2> <ul> <?php while (have_posts()) : the_post(); ?> <li><span class="title"><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></span> <span class="meta"></span></li> <?php endwhile; ?> </ul> <br /> <p class="link"><a href="<?php echo get_option('home'); ?>/archives" title="View Archives">View Archives</a></p> The the first line in the code will display the last 10 posts from all categories. this one: <?php query_posts('showposts=10'); ?> But I want to display the last 10 posts from all categories EXCEPT for the newest post in category 12. so the formula should look something like this... <?php query_posts('showposts=10 BUT DO NOT INCLUDE THE NEWEST POST FROM CAT 12 '); ?> I'm not sure how to do this, can anyone help? Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted December 22, 2010 Share Posted December 22, 2010 Try this, but not tested. <?php query_posts('showposts=10&cat=-12'); ?> Quote Link to comment Share on other sites More sharing options...
phpchick Posted December 22, 2010 Author Share Posted December 22, 2010 Not solved, I hit the solved button because I thought it was at first but then I did some more checking. this <?php query_posts('showposts=10&cat=-12'); ?> is saying to show the latest 10 posts from every category except cat 12. I want to do: show the latest 10 posts from every category except for only the first post from cat 12 Your statement takes out every single post from cat 12 Quote Link to comment Share on other sites More sharing options...
phpchick Posted December 22, 2010 Author Share Posted December 22, 2010 I feel like I should be using some sort of offset=1 type of thing (cause that will skip the first one) but I don't know how to apply that only for cat 12 and not have it affect anything else..... :/ Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted December 22, 2010 Share Posted December 22, 2010 Try this, but again not tested... <?php $query = new WP_Query('cat=12&order=DESC'); ?> <?php if ( $query->have_posts() ) : $query->the_post(); $last_post = $post->ID; ?> <?php endif; ?> <?php query_posts('showposts=11'); ?> <?php while(have_posts()) : the_post(); if(!($last_post == $post->ID)) : ?> <?php // add your stuff here ?> <?php endif; endwhile; ?> Play around with it and i am sure you will get it working. Good luck! EDIT: You don't need offset for it. The adding new query would work. Quote Link to comment Share on other sites More sharing options...
phpchick Posted December 23, 2010 Author Share Posted December 23, 2010 that worked. thank you so much!!! I cant thank you enough. Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted December 23, 2010 Share Posted December 23, 2010 that worked. thank you so much!!! I cant thank you enough. Glad to hear, that it worked for you. Cheers Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.