[wp-hackers] Re: get_posts / query_posts need a pro

Andrew Ozz admin at laptoptips.ca
Tue Mar 11 06:02:35 GMT 2008


Try:
<?php
$myposts = get_posts('numberposts=1&category=3');
$mypost = $myposts[0];
setup_postdata($mypost);
?>

then 1st line in the loop:
<?php if ( $post->ID == $mypost->ID ) continue; ?>

Just an idea, not tested...

Mr. Awesome wrote:
> Hmm, I think I have something here... well, almost doing what I want it 
> to do...
> 
> UPPER POST SECTION:
> 
> <div id="announcement-post">
> 
> 
> <?php
> global $post;
> $myposts = get_posts('numberposts=1&category=3');
> foreach($myposts as $post) :
> setup_postdata($post);
> ?>
> 
> <div class="post" id="post-<?php the_ID(); ?>">
> <div class="date">
>                <span class="monthyear"><?php the_time('F') ?></span>
>                <div class="day"><?php the_time('j') ?></div>
>                <span class="monthyear"><?php the_time('Y') ?></span>
>                </div><h2 class="posttitle"><a href="<?php 
> the_permalink() ?>" rel="bookmark" title="<?php _e('Permanent link to'); 
> ?> <?php the_title(); ?>"><?php the_title(); ?></a></h2>
>                          <p class="postmeta"> <?php _e('Filed under'); 
> ?> <?php the_category(', ') ?>
>                <?php edit_post_link(__('Edit'), ' &#183; ', ''); ?>
>                </p>
>                <div class="postentry">
>                <?php if (is_search()) { ?>
>                    <?php the_excerpt() ?>
>                <?php } else { ?>
>                    <?php the_content(__('Read the rest of this entry 
> &raquo;')); ?>
>                <?php } ?>
>                </div>
>                          <p class="postfeedback">
>                <?php comments_popup_link(__('comments (0)'), 
> __('comments (1)'), __('comments (%)'), 'commentslink', __('comments 
> off')); ?>
>                </p>                              <!--
>                <?php trackback_rdf(); ?>
>                -->
> </div> <?php endforeach; ?>
> 
> 
> Doing THAT there, shows ONE post from that ONE category, including it's 
> CONTENT using <?php
> global $post;
> $myposts = get_posts('numberposts=1&category=3');
> foreach($myposts as $post) :
> setup_postdata($post);
> ?>.
> 
> The lower section is using the normal loop so far... So, whatever is 
> posted in the top, will show in the lower section with normal posts 
> though... but I don't think that's a big deal... it's basically 
> archived.. and the "< previous entries" link works fine too.. I THINK I 
> got something here... notice I said .. "I THINK" lmao... It looks like 
> it's working just fine.. so.. =D
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
> 


More information about the wp-hackers mailing list