2015-02-04 2 views
1

테마를 만드는 중입니다. 작성자가 single.php 페이지에 표시되도록 할 수 없습니다. 사이트의 하단에 표시되지만 헤드 라인의 첫 번째 통화에는 표시되지 않습니다.작성자가 single.php에 표시되지 않습니다

<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> 

두 번째로 루프 내에서 호출되면 정상적으로 작동합니다.

<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> 

처음으로 전화를 걸면 왜 표시되지 않습니까?

+0

나는 WP 전문가가 아니지만'echo the_author();'와'echo $ post-> post_author;'의 차이점은 무엇입니까? 만약'the_author()'가'have_posts()'를 반복 할 때만 반환 될 것이라고 추측해야한다면, – MonkeyZeus

+0

이 작동하는지 확실하지 않습니다.- the_author (get_the_ID()); – Neil

답변

1

(codex) - 루프 내에 있어야합니다.

+0

알겠습니다. 루프 외부에 표시 할 수 없다는 뜻입니까? – krillebimbim

+0

이 맞습니다. 먼저 코드에서 루프를 시작하는 것이 좋습니다. – Mark

+0

방금했는데 완벽하게 작동했습니다. 귀하의 의견을 보내 주셔서 감사합니다. – krillebimbim

관련 문제