简体   繁体   中英

The author doesn't show in single.php

I am in the process of creating a theme and I can't get the author to be displayed on the single.php page. It's displayed lower on the site but doesn't seem to show in the first call under the headline.

<header class="intro-header" style="background-image: url('http://i.imgur.com/ZyZMhQv.jpg')">
    <div class="container">
        <div class="row">
            <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
                <div class="site-heading">
                    <h1><?php the_title(); ?></h1>
                    <hr class="small">
                    <span class="subheading">Posted by <?php the_author(); ?> on <?php the_time('F jS, Y'); ?></span>
                    <div id="avatar" class="row text-center"><?php echo get_avatar( $post->post_author, 92 ); ?> </div>
                </div>
            </div>
        </div>
    </div>
</header>

The second time it's called within the loop it works fine.

<div class="row">
    <div class="col-md-6 col-md-offset-3">
        <div class="panel panel-default panel-body">

        <?php while(have_posts()) : the_post(); ?>
            <p> Posted by <?php the_author(); ?> on <?php the_time('F jS, Y'); ?> </p>
            <p> <?php the_content(''); ?> </p>
            <?php endwhile; wp_reset_query(); ?>
        </div>
    </div>

Why doesn't it show up the first time it's called?

按照法典 -必须在循环内。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM