using get_posts twice on a page?
-
I’m trying to setup two separate sections on a page using get_posts and pulling different groups of posts based on a custom field. Each get_posts works independently, but when both on the same page, only the first works properly. I”m thinking this is a variable problem, but still very new to PHP and not sure how to easily remedy.
<!-- Latest News --> <?php $news_tag = get_post_meta($post->ID, 'news-tag', true); $postslist = get_posts('tag='.$news_tag.'&numberposts=10&order=ASC&orderby=date'); foreach ($postslist as $post) : setup_postdata($post); ?> <div> <?php the_date(); ?> - <a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a> </div> <?php endforeach; ?> <!-- End News --> <!-- Upcoming Events --> <?php $events_tag = get_post_meta($post->ID, 'events-tag', true); $postslist = get_posts('tag='.$events_tag.'&numberposts=10&order=ASC&orderby=name'); foreach ($postslist as $post) : setup_postdata($post); ?> <div> <a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a> </div> <?php endforeach; ?> <!-- End Events-->
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘using get_posts twice on a page?’ is closed to new replies.