@esmi
I’ve tried that already, but i could’nt make it work..
Perhaps you could give me an example?
See this Codex page for an example using query_posts.
It doesnt work..
The code is placed outside the loop..
Wich makes it a bit more difficult..
Sorry? The code snippet you posted above clearly shows part of the Loop.
It is actually in the header.php..
It displays the most recent post in the topbanner.
And the most recent post is then removed from the loop with:
<?php query_posts('posts_per_page=6&offset=1'); ?>
In that case, you have multiple Loops on the 1 page, so you would be better off using get_posts or WP_Query for the secondary queries. Same arguments but get_posts uses a foreach loop.
http://codex.wordpress.org/Function_Reference/get_posts
Ok, now it looks like this:
<?php
$args = array( 'numberposts' => 1, 'orderby' => 'recent' );
$rand_posts = get_posts( $args );
foreach( $rand_posts as $post ) : ?>
<li><a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail(); ?>
<div id="newestpost" class="bg50 absolute">
<h1 href="<?php the_permalink(); ?>"><?php the_title(); ?></h1>
</div></a></li>
<?php endforeach; ?>
Now, what do i do to exclude a category?
It doesnt seem to work if i use:
<?php query_posts( '&cat=-7,-8,-9'); ?>
$args = array( 'numberposts' => 1, 'orderby' => 'recent', 'cat => -7,-8,-9' );
Wow! that simple..
Thanks for the help, i really appreciate it! π
Glad it’s working now. π
Just found out that the new code causes the next_post_link and previous_post_link to not work properly..
If i change the “$rand_posts as $post“-part to for example, “$posts as $post” the tags work again, but then the code doesnt work.. π
Try adding <?php wp_reset_query();?> after <?php endforeach; ?>
Its works now π Thank you π