Don’t understand how to do get_posts multiple times on same page.
-
Hi,
I’m very amateur at this. I’m trying to use WordPress to publish blocks of text on certain pages.
For instance on this home page: “https://marinifc.org/index.php” I need to publish a post in the left hand column (board members), and publish a block of news in the middle column (sometimes several posts).
Therefore I created a board list category and a news category, and made entries for each.
So then I need to know how to populate each block with the different categories’ posts.
Right now I’m populating the middle block with this code:
<?php
require('wp-blog-header.php');
?>
<?php
$posts = get_posts('numberposts=5&category=5');
foreach ($posts as $post) : start_wp(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><?php the_title(); ?></h2><div class="entry">
<?php the_content('Read the rest of this entry »'); ?>
<br></div>
</div>
<?php endforeach; ?>This works fine. However, if I try to re-use the code to get another category, I get the second entry for that category, but not the first. Possibly I should be using something other than get_posts? I’m a definite novice so if anyone could point me in the right direction, that would be great. I actually did read through a lot of the basic documentation – but still am in a bit of a fog about the whole thing.
- The topic ‘Don’t understand how to do get_posts multiple times on same page.’ is closed to new replies.