2017-10-02 4 views
-4

더 많은 게시물이 있더라도 결과가 10 개만 표시되는 이유는 무엇입니까?페이지에 표시되는 게시 결과 수를 변경하는 방법

<div class="job-cont"> 
 
    \t \t <?php 
 
    \t \t $query = new WP_Query(array('post_type' => 'jobs')); 
 

 
\t \t \t if ($query->have_posts()) : 
 

 
    \t \t \t \t while ($query->have_posts()) : $query->the_post(); ?> 
 
    \t \t \t \t <div class="title_image_container"> 
 
     \t \t \t <a href="<?php the_permalink(); ?>"> 
 
       \t \t \t <h1 class="the_job_title"><?php the_title(); ?></h1> 
 
       \t \t \t <img class="the_job_image" src="<?php the_post_thumbnail();?> 
 
      \t \t \t </a> 
 
    \t \t \t \t </div> 
 
    \t \t \t <?php endwhile; 
 

 
\t \t \t endif; 
 
    \t \t ?> 
 
\t \t 
 
\t \t </div>

그것은 내가 페이지에 보여 싶은 게시물의 수를 변경하는 방법이 ?

나는 모든이 일을하려고 준비했지만 아직 결과가없는 :

function number_of_posts_per_page($number) { 
     if (is_home()) { 
     $number->set('posts_per_page', 15);   
    } 

    add_action('pre_get_posts', 'number_of_posts_per_page'); 
+0

무엇? 좀 더 자세한 내용을 말하면서 당신이 말하는 바가 무엇인지 모릅니다 – user5014677

+0

예. 죄송합니다. 지금 이해하는 것이 좋습니다. – Caesar

답변

2

워드 프레스 페이지 당 10 게시물과 같은 기본 설정이 있습니다. -1은 무제한을 의미합니다 경우 아래의 코드와 같이 직접 루프 쿼리에서 페이지 당 최대 게시물을 조정할 수있는 사용자 정의 포스트 유형의

읽기> - 블로그 게시물에 대한

, 당신은 설정에서 설정을 조정할 수 있습니다.

$query = new WP_Query(array('post_type' => 'jobs', 'posts_per_page' => -1));