This works for me.
<?php $postslist = get_posts('category=1&numberposts=1&order=DESC&orderby=post_date');
foreach ($postslist as $post) :
setup_postdata($post); ?>
<div class="post_item">
<span class='side_date'><?php the_time('F j, Y'); ?></span><br />
<a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
<?php the_excerpt(); ?>
</div>
<?php endforeach; ?>
Hi, I´m trying to show last post on my home page and I try using your code
THe thing is I will like to show lastes post but excluding some categories. So with out know well programming I just copy&paste your code and made this modification but still showme a post that I put on the exclude
.
<div id="lastest-post">
<?php $postslist = get_posts('numberposts=1&order=DESC&orderby=post_date&exclude=142,143,144,157');
foreach ($postslist as $post) :
setup_postdata($post); ?>
<div>
<h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
<h4><?php the_excerpt(); ?></h4>
</div>
<?php endforeach; ?>
</div>
Any advice ?
Try reading the Docs: Template_Tags/get_posts
What you did: excluded the posts having those IDs. If you want to exclude a category, see the documentation.