2017-03-06 1 views
1

내가 부트 스트랩과 워드 프레스를 병합와 나는 이런 식으로 뭔가를 얻을 수 원하는을 보여니까. 다음은 루프이며 블로그를 보여주는 ...하지만 그 빈 상자를 보여 ...워드 프레스는 블로그 페이지는 블로그

내가 뭘 잘못 했니? 아니면 더 좋은 방법이 있을까요?

<div class="wrapper"> 

    <?php 
     $rest_query = new WP_Query(array(
      'orderby' => 'post_date', 
      'order' => 'DESC', 
      'post_type' => array('post'), 
      'post_status' => 'publish' 
    )); 

    if($rest_query->have_posts()): 
    ?> 

    <?php while($rest_query->have_posts()): $rest_query->the_post(); ?> 

    <?php 
     if ($rest_query->current_post == 0) 
     { 
      echo '<div class="row"> 
      <div class="col-md-6"> 
       <div class="single first-post"> 
        <a href="<?php the_permalink(); ?>"><div class="thumb"><?php the_post_thumbnail(); ?></div></a> 
        <div class="content"> 
         <a href="<?php the_permalink(); ?>"><h1><?php the_title(); ?></h1></a> 
         <div class="data"> 
          <p class="date"><?php echo get_the_date();s ?></p> 
          <p class="social">0 shares/0 comments</p> 
         </div> 
        </div> 
       </div> 
      </div> 
      <div class="middleLine"></div> 
      <div class="col-md-6"></div> 
     </div>'; 
     } 
     elseif ($rest_query->current_post == 1) 
     { echo '<div class="row"> 
      <div class="col-md-6"></div> 
      <div class="middleLine"></div> 
      <div class="col-md-6"> 
       <div class="single secound-post"> 
         <a href="<?php the_permalink(); ?>"><div class="thumb"><?php the_post_thumbnail(); ?></div></a> 
         <div class="content"> 
          <a href="<?php the_permalink(); ?>"><h1><?php the_title(); ?></h1></a> 
          <div class="data"> 
           <p class="date"><?php echo get_the_date();s ?></p> 
           <p class="social">0 shares/0 comments</p> 
          </div> 
         </div> 
       </div> 
      </div> 
     </div>'; } 
    ?> 

    <?php endwhile; ?> 

    <?php endif; ?> 
</div> 

답변

1

페이지에 표시하는 동안 일부 코드 오류가 있다고 생각합니다. ECHO를 사용하는 동안 PHP 태그를 사용해서는 안되며, 이것이 귀하의 경우에는 효과가 없습니다.

코드를 개정 :

<div class="wrapper"> 

<?php 
    $rest_query = new WP_Query(array(
     'orderby' => 'post_date', 
     'order' => 'DESC', 
     'post_type' => array('post'), 
     'post_status' => 'publish' 
)); 

if($rest_query->have_posts()): 
?> 

<?php while($rest_query->have_posts()): $rest_query->the_post(); ?> 

<?php 
    if ($rest_query->current_post == 0) 
    { 
     echo '<div class="row"> 
     <div class="col-md-6"> 
      <div class="single first-post"> 
       <a href="'.the_permalink().'"><div class="thumb">'.the_post_thumbnail().'</div></a> 
       <div class="content"> 
        <a href="'.the_permalink().'"><h1>'.the_title().'</h1></a> 
        <div class="data"> 
         <p class="date">'.get_the_date().'</p> 
         <p class="social">0 shares/0 comments</p> 
        </div> 
       </div> 
      </div> 
     </div> 
     <div class="middleLine"></div> 
     <div class="col-md-6"></div> 
    </div>'; 
    } 
    elseif ($rest_query->current_post == 1) 
    { echo '<div class="row"> 
     <div class="col-md-6"></div> 
     <div class="middleLine"></div> 
     <div class="col-md-6"> 
      <div class="single secound-post"> 
        <a href="'.the_permalink().'"><div class="thumb">'.the_post_thumbnail().'</div></a> 
        <div class="content"> 
         <a href="'.the_permalink().'"><h1>'.the_title().'</h1></a> 
         <div class="data"> 
          <p class="date">'.get_the_date().'</p> 
          <p class="social">0 shares/0 comments</p> 
         </div> 
        </div> 
      </div> 
     </div> 
    </div>'; } 
?> 

<?php endwhile; ?> 

<?php endif; ?> 

참고 : 당신은 내가 코드 위에 표시 한대로 그것을 사용해야 후 어떤 PHP 변수를 인쇄합니다.

고맙습니다.