2016-07-14 40 views
0

所以我正在製作一個網站,並遇到了顯示的自定義帖子類型的問題。基本上,我有一個稱爲資源的職位類型。資源分爲三種不同的類別:統計,非統計和臨牀。爲什麼我的16個帖子中只有10個被顯示?

以下是資源後期編輯頁面的樣子。 resource post editing 如您所見,底部有一個下拉菜單供用戶決定觀衆。以下是我用來將資源頁面上的資源分類到各個部分的代碼。

<?php $args = array(
'post_type' => 'resource', 
'order'  => 'ASC'); 
$loop = new WP_Query($args);  
while ($loop->have_posts()) : $loop->the_post(); 
    $resource_type = get_field('resource_type'); 
    $audience = get_field('audience'); 
    $forStat = "For Statisticians"; 
    $notForStat = "For Non-Statisticians"; 
    $clinical = "Clinical Trials"; 
    $hasLink = FALSE; 
    if (get_field(resource_link)){ 
     $hasLink = TRUE; 
     $resource_link = get_field('resource_link'); 
    } else { 
     $resource = get_field('resource'); 
    } 
    ?> 

    <?php if ($audience == $forStat) { ?> 

     <?php if ($hasLink) { ?> 
      <a href="<?php echo $resource_link; ?>"><button type="button" class="list-group-item"><?php the_title(); ?></button></a> 
     <?php } else { 
      $resourceUrl = $resource['url']; ?> 
      <a href="<?php echo $resourceUrl; ?>"><button type="button" class="list-group-item"><?php the_title(); ?></button></a> 
     <?php } ?> 

    <?php } ?> 

<?php endwhile;?> 

以下是資源頁面,讓你可以看到正在顯示只有10個職位,即使有16個資源統計員。 The website resource page.

任何想法爲什麼只有前10個資源被顯示?

+0

你(或你的框架)如何管理分頁..? – scaisEdge

回答

2

添加

'posts_per_page' => -1, 

作爲參數。

$args = array(
    'post_type' => 'resource', 
    'order'  => 'ASC', 
    'posts_per_page' => -1 
); 
相關問題