0

나는 wordpress로 사용자 정의 테마를 만들고 내 뉴스 항목에 대한 사용자 정의 게시물 유형 아카이브를 만들었습니다. paginate()를 사용하고 싶습니다. 기능을 사용하여 내 항목을 탐색합니다. 이 기능은 아직 작동하지 않습니다. 무엇을 잘못하고 있습니까?wordpress, paginate function does not work (사용자 정의 테마)

<div class="col-md-12"> 
      <?php 

      $args = array('post_type' => 'nieuws-item'); 
      $the_query = new wp_query($args); 

      while($the_query -> have_posts()) : $the_query -> the_post();?> 

        <div class="col-md-6 left"> 
         <div class="content-holder-nieuws fc3 left"> 
          <h6><?php the_title(); ?></h6> 
          <h6 class="month fc2 left"><?php echo (types_render_field("nieuws-maand", array("output"=>"normal"))); ?></h6> 
          <div class="news-discription left"> 
           <p class="fc5 left"> 
            <?php the_excerpt(); ?> 
           </p> 
           <a href="<?php the_permalink(); ?>" class="left read-more"> 
            <img src="<?php bloginfo('template_url'); ?>/img/readmore-border.png" class="readmore-border"> 
            lees meer 
           </a> 
          </div> 
         </div> 
        </div> 
      <?php endwhile; ?></div> 

     <div class="col-md-12 overview-navigation left"> 

      <?php paginate_links(); ?> 

     </div> 

답변

0

사용자 정의 포스트 유형에는 아카이브 기능이 내장되어 있으므로 활성화해야합니다. register_post_type() 호출에서 'has_archive'를 true로 설정하십시오.

그런 다음 보관 파일 페이지에 대한 템플릿 파일을 만듭니다 (표준 블로그와 형식이 다른 경우). 귀하의 경우에 나는 당신이 그것을 archive-nieuws-items.php라고 부르기를 원할 것입니다. 아카이브 페이지에서 예제의 사용자 정의 버전 대신 표준 포스트 루프를 간단하게 사용할 수 있습니다.

이 접근 방식을 사용하면 효율성을 높이고 페이지 매김 문제를 처리 할 수 ​​있습니다.

추가 읽기 : https://codex.wordpress.org/Function_Reference/register_post_type https://developer.wordpress.org/themes/basics/template-hierarchy/