dongyang1518 2014-07-14 19:52
浏览 24

Wordpress:在作者的最新帖子之前获取

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?

  • 写回答

2条回答 默认 最新

  • dscbxou1900343 2014-07-14 20:51
    关注

    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

    评论

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改