foreach repeats the content of last post
-
Hello all,
I am new to wordpress and trying to show multiple posts content, date and link in one page. I have written the following code and it works well for dat and the hyper link but for the content the_excerpt code just repeat the content of the last post for all of them. I also tried the_content and it did not worked as well.
I would be happy if you check my code and let me know what its problem is.
<h1><img class="icon" src="/wp-content/themes/rvu/images/icon_news.png">RVU News</h1> <ul class="news"> <?php global $post; $myposts = get_posts('numberposts=3&category=20'); foreach($myposts as $post) : ?> <li> <span class="date"><?php the_time('F j, Y'); ?></span><br /> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <?php the_excerpt(); ?></li> <?php endforeach; ?> <li><a href="/category/news/">More news...</a></li> </ul>
- The topic ‘foreach repeats the content of last post’ is closed to new replies.