Jump to content

Such an easy problem but I don't know how to do it...


phpchick

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.