I have a code that can get and display posts just before the latest post:
<?php global $post; $myposts = get_posts('numberposts=2&offset=1&category=67');
foreach($myposts as $post) : ?>
<?php endforeach; ?>
but how can I include the author? I try using
<?php the_author(); ?>
but it doesn't work.
How to get the post and the author?
I'm pretty sure you need
foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
for that to work and to also get <?php the_permalink(); ?>
and <?php the_title(); ?>
You're missing the setup_postdata( $post )
part
Try this...
<?php global $post; $myposts = get_posts('numberposts=2&offset=1&category=67&author=123');
foreach($myposts as $post) : ?>
<?php endforeach; ?>
Another better method is...
$args = array(
'posts_per_page' => 8,
'author' => 123,
'cat' => 123,
'offset' => 1,
);
<?php global $post; $myposts = get_posts($args);
foreach($myposts as $post) : ?>
<?php endforeach; ?>