在Wordpress中获取帖子作者

时间:2011-11-05 15:36:45

标签: wordpress wordpress-theming

我正在从HTML页面构建Wordpress模板。

我目前有

<?php $queried_post = get_post( $_GET['id'], $output ); ?>

然后我用......

<?php echo $queried_post->post_title; ?>

这适用于回显帖子标题。

然后我试着回应作者...

<?php echo $queried_post->post_author; ?>

我找回'1',这不是作者姓名。这是如何正确完成的?

1 个答案:

答案 0 :(得分:1)

试试这段代码:

<?php the_author($_GET['id']); ?>

食典条目:http://codex.wordpress.org/Function_Reference/the_author


我的single.php文件:

<?php get_header(); ?>

<?php if (have_posts()): ?>
  <?php while (have_posts()): the_post(); ?>
    <div class="post post-single">
      <h1 class="post-title">
        <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
        <?php edit_post_link('Edit', '', ''); ?>
      </h1>

      <div class="content"><?php the_content(); ?></div>
    </div>
  <?php endwhile; else: ?>
  There are no posts to display.
<?php endif; ?>

<?php get_footer(); ?>
相关问题