2013-08-28 3 views
1

죄송합니다. 저는 처음부터 WordPress 코딩 및 학습에 익숙합니다. 저의 경험 부족을 용서해주십시오.Date Base Archive on WordPress Homepage

'제품'이라는 사용자 정의 게시 유형이 있고이를 홈페이지에 날짜 기반 보관 파일로만 표시하려고합니다. 그러나, 나는 그 날짜에 처음 3 개 또는 4 개의 게시물의 특집을 제외한 게시물의 제목이나 다른 내용을 표시하고 싶지 않습니다. 이런 식으로 뭔가 :

This is what I want to do

나는 다음과 같은 코드를 시도하고 있지만 일반 루프와 게시물을 반환합니다.

<?php $query = new WP_Query(array('post_type' => 'products', 'orderby' => 'date')); ?> 
    <?php if ($query->have_posts()) : ?> 

     <?php /* Start the Loop */ ?> 
     <?php while ($query->have_posts()) : $query->the_post(); ?> 

      <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 
      <?php 
       $archive_year = get_the_time('Y'); 
       $archive_month = get_the_time('m'); 
       $archive_day = get_the_time('d'); 
      ?> 
      <div class="idpostdate"> 
       <a href="<?php echo get_day_link($archive_year, $archive_month, $archive_day); ?>"><?php the_date('F j, Y', '', '<span class="datetext">: Click Here To View Products</span>', true);?></a> 
      </div> 
      <div class="thumbnail"> 
       <?php if (has_post_thumbnail()) { the_post_thumbnail('homet'); } ?> 

      </article> 

     <?php endwhile; ?> 


    <?php else : ?> 

     <?php get_template_part('no-results', 'index'); ?> 

    <?php endif; ?> 

어떤 지침이 있습니까?

답변

1

the_post_thumbnail()과 같은 기능은 주 쿼리에서 실행됩니다. 코드에서 해당하는 코드를 사용하려면 코드 앞에 $query->을 추가해야합니다.

테스트되지 않은,하지만 난 당신이 원하는 일을 할 수있을 거라 생각 :

<?php $query = new WP_Query(array('post_type' => 'products', 'orderby' => 'date')); ?> 
<?php if ($query->have_posts()) : ?> 

    <?php /* Start the Loop */ ?> 
    <?php while ($query->have_posts()) : $query->the_post(); ?> 

     <article id="post-<?php $query->the_ID(); ?>" <?php $query->post_class(); ?>> 
     <?php 
      $archive_year = $query->get_the_time('Y'); 
      $archive_month = $query->get_the_time('m'); 
      $archive_day = $query->get_the_time('d'); 
     ?> 
     <div class="idpostdate"> 
      <a href="<?php echo get_day_link($archive_year, $archive_month, $archive_day); ?>"><?php $query->the_date('F j, Y', '', '<span class="datetext">: Click Here To View Products</span>', true);?></a> 
     </div> 
     <div class="thumbnail"> 
      <?php if ($query->has_post_thumbnail()) { $query->the_post_thumbnail('homet'); } ?> 

     </article> 

    <?php endwhile; ?> 


<?php else : ?> 

    <?php get_template_part('no-results', 'index'); ?> 

<?php endif; ?>