2017-06-17 15 views
0

私はアーカイブページに表示されている投稿のnumbrerを変更したいと思います。 そのことを教えてください、ありがとうございます。アーカイブページにカスタム数の投稿を表示する方法は?

これは私がアーカイブページの投稿の異なる数を持つようにしたい私のarchive.php

<div id="content-a"> 

<?php if (have_posts()) : ?> 
<?php while (have_posts()) : the_post(); ?> 

<div class="post"> 
<div class="imgdiv"><a href="<?php the_permalink() ?>"><img src="<?php echo catch_that_image() ?>" width="250"></a></div> 
<div class="p-heading"><h1><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1></div> 
<div class="p-content"><?php the_excerpt(); ?></div> 
<div class="p-info"><?php the_time('j.m.Y') ?> | <?php the_category(', '); ?> | <img src="http://www.virmodrosti.com/wp-content/uploads/comments.png" alt="Komentarji" width="26" height="12"><?php $totalcomments = get_comments_number(); echo $totalcomments; ?></div> 
</div> 

<?php endwhile; ?> 

からコードです。ありがとうございました。

答えて

3

あなたのfunctions.phpにこのコードを追加し、代わりにポストの番号を100から変更します。

function wpsites_query($query) { 
if ($query->is_archive() && $query->is_main_query() && !is_admin()) { 
     $query->set('posts_per_page', 100); 
    } 
} 
add_action('pre_get_posts', 'wpsites_query'); 

この

function SearchFilter($query) { 
    if ($query->is_search) { 
     $query->set('post_type', 'archive'); 
     $query->set('posts_per_page', 100); 
    } 
    return $query; 
} 
add_filter('pre_get_posts','SearchFilter'); 
+0

ありがとうしてみてください。このルールを検索結果にも適用したい場合は、is_archiveの後にis_searchを追加するだけですか? – Techuser

+0

チェック私は答えを更新しましたが、最後に変更する前に試してください。 –

+0

ありがとう、それは正常に動作します。 – Techuser

関連する問題