2013-11-26 3 views
0

내부에 HTML을 추가이 코드가 워드 프레스 루프

 <div class="row-fluid"> 
      <div class="span6"> 
      <h3>UPCOMING DEBATES</h3> 
      <?php 
      $query = new WP_Query(array(
      'post_type' => 'debate', 
      'post_status' => 'future', 
      'orderby' => 'date', 
      'order' => 'ASC', 
      'posts_per_page' => 1 
     )); 

     if($query->have_posts()) { 
      while($query->have_posts()) { 
       $query->the_post(); 



      } 
     } 
     ?> 
      </div> 

을 그리고 그 if($query->have_posts()) { 안에 나는이 코드를 추가 할 :

<div class="post-title box"> 

    <h1 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1> 


</div> 

<?php if (has_post_thumbnail()) { ?> 

<div class="entry-image" style="<?php echo $max_height; ?>"><?php 

    $src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'large', false, ''); ?> 

    <a href="<?php echo $src[0]; ?>" class="lightbox" title="<?php the_title(); ?>" rel="bookmark"> 

     <?php the_post_thumbnail($featured_image_size); ?> 

    </a> 

</div> 
<?php } ?> 

이 코드는 post_titlethumbnail_image 검색됩니다.

문제는이 코드를 첫 번째 코드 안에 추가하는 방법을 모르겠다는 것입니다.

내 안에 넣으려고했는데 if($query->have_posts()) { 경우 작동하지 않습니다. 복사 및 붙여 넣기보다 복잡해 보입니다.

어떻게해야합니까? 저는 PHP 초급자입니다.

답변

0

이 시도 :

<div class="row-fluid"> 
     <div class="span6"> 
     <h3>UPCOMING DEBATES</h3> 
     <?php 
     $query = new WP_Query(array(
     'post_type' => 'debate', 
     'post_status' => 'future', 
     'orderby' => 'date', 
     'order' => 'ASC', 
     'posts_per_page' => 1 
    )); 

    if($query->have_posts()) { 
     while($query->have_posts()) { 
      $query->the_post(); 

    ?> 

     <div class="post-title box"> 
      <h1 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1> 
     </div> 

     <?php if (has_post_thumbnail()) { ?> 

      <div class="entry-image" style="<?php echo $max_height; ?>"><?php 
       $src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'large', false, ''); ?> 
       <a href="<?php echo $src[0]; ?>" class="lightbox" title="<?php the_title(); ?>" rel="bookmark"> 
       <?php the_post_thumbnail($featured_image_size); ?> 
       </a> 
      </div> 

     <?php } 

     } 
    } 
    ?> 
     </div>