2017-04-19 64 views

回答

0

您可以更改後端每頁的帖子數。設置 - >閱讀。在那裏你可以改變它的地方:「博客頁面最多顯示」。

1

就在你的論點

'posts_per_page' => -1 

然後你做添加此。

還有一件事:你可以將默認設置從管理改爲10以外的其他設置。轉到WordPress管理 - 設置 - 閱讀。有一個選項,如「博客頁面最多顯示」。輸入你想要的默認文章數量。

它將改變設置的所有網頁,但如果你想使這一變化僅適用於標籤頁,然後在你的情況,你可以更改環tag.php文件中的代碼如下:

global $wp; 
$s_array = array('posts_per_page' => -1); // Change to how many posts you want to display 
$new_query = array_merge($s_array, (array)$wp->query_vars); 
query_posts($new_query); 
<?php 
if (have_posts()) : while (have_posts()) : the_post(); ?> 
<!-- Here I grab the image from the post with that tag --> 
<?php endwhile; ?> 
<?php wp_reset_query();?> 
1

要顯示你有每個職位是10.請參閱下面的代碼覆蓋它的默認顯示類別模板的所有帖子:

$args = array('posts_per_page' => -1); 
$the_query = new WP_Query($args); 

while ($the_query->have_posts()) { 
    $the_query->the_post(); 
    /** Your code here **/ 
} 

顯示所有的職位上,模板是不是一個好的做法,相反,我會推薦每頁顯示10篇文章並顯示分頁。

參考資料分頁:https://codex.wordpress.org/Pagination

相關問題