Excluding current post from get_posts()
-
I’m trying to display a list of posts from a certain category in my sidebar. I want to exclude the current post from the list. My code so far is:
<ul> <?php global $post; $postid = $post->ID; $myposts = get_posts("category=4&exclude=".$postid."&numberposts=1&orderby=rand"); foreach($myposts as $post){ ?> <li><a>"><?php the_title(); ?></a></li> <?php } ?> </ul>But this doesn’t seem to work. Where am I going wrong?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Excluding current post from get_posts()’ is closed to new replies.