Retrieving and displaying a post – am I using “get_post” correctly?
-
I am trying to put a section on my main page that grabs the latest post from a particular category and displays it. Here’s my code:
<?php
$posts =
get_posts("order=ASC&category_id=2&&numberposts=1");
foreach ($posts as $post) :
?><a>"><?php the_title(); ?></a>
<br>
<h2>
<?php the_content(); ?>
</h2><?php endforeach; ?>
Doesn’t work well, though. It just gets the most recent post, regardless of what category it is in – and also won’t display the post content. Any ideas?
- The topic ‘Retrieving and displaying a post – am I using “get_post” correctly?’ is closed to new replies.