kinggror
Member
Posted 2 years ago #
I'm trying to add the most recent post of a category to the bottom of a static home page.
The statis home page is using its own unique template that I have been trying to edit, but when I use the the_content() it only dipslays the content of the static page, not the posts I'm trying to query.
I'm new to wordpress, so I think I'm missing something rather simple, just cant figure it out... any ideas?
kinggror
Member
Posted 2 years ago #
Perfect, I was using it incorrectly. Thanks for the help and below is the final code i used.
<?php
global $post;
$myposts = get_posts('numberposts=1&offset=0&category=blog');
foreach($myposts as $post) :
setup_postdata($post); ?>
<h2 class="posttitle"><?php the_title(); ?></h2>
<div class="postmetadata"><?php the_time(get_option('date_format').', '.get_option('time_format')) ?> <!-- <?php _e('by') ?> <?php the_author() ?> --></div>
<div class="post">
<?php the_excerpt(); ?>
</div>
<?php endforeach; ?>