WordPress: функция изменения количества сообщений, отображаемых в архиве. Php не работает

Попытка увеличить количество сообщений, отображаемых на страницах архива (архивы / теги / категории / и т. Д.). Хотя я использую эту функцию, она по-прежнему отображает только 4, есть идеи, что не так? Я пытался с wp_reset_query(); функционировать как раньше $posts и в начале функции:

archive.php:

    <?php if (have_posts()) : ?>

<?php
$post = $posts[0]; // Hack. Set $post so that the_date() works.
?>

<?php /* If this is a category archive */ if (is_category()) { ?>
<div class="bumper">&nbsp;</div>
<div id="mainContent" class="clearfix">
<div id="archiveWrap" class="clearfix">
<h2>Test1.3: <?php single_cat_title(); ?>sarkiv</h2>

<?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
<h3>Posts Tagged &#8216;<?php single_tag_title(); ?>&#8217;</h3>

<?php /* If this is a daily archive */ } elseif (is_day()) { ?>
<h><?php the_time('F jS, Y'); ?></h3>

<?php /* If tahis is a monthly archive */ } elseif (is_month()) { ?>
<h3><?php the_time('F, Y'); ?></h3>

<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
<h3> <?php the_time('Y'); ?></h3>

<?php /* If this is an author archive */ } elseif (is_author()) { ?>
<h3>Author Archive</h3>

<?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
<h3>Blog Archives</h3>

<?php } ?>

<?php include (TEMPLATEPATH . '/inc/nav.php' ); ?>

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

<div <?php post_class() ?>>

<h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>

<?php include (TEMPLATEPATH . '/inc/meta.php' ); ?>

<div class="entry">
<?php the_content(); ?>
</div>

</div>

<?php endwhile; ?><?php include (TEMPLATEPATH . '/inc/nav.php' ); ?>

<?php else : ?>

<h3>Nothing found</h3>
</div>
</div>
</div>
<?php endif; ?>

functions.php:

 function post_per_page_control( $query ) {

if ( is_admin() || ! $query->is_main_query() )
return;

// Archive
if ( is_archive() ) {
//control the numbers of post displayed/listed (eg here 10)
$query->set( 'posts_per_page', 10 );
return;
}
// Category
if ( is_category() ) {
//control the numbers of post displayed/listed (eg here 10)
$query->set( 'posts_per_page', 10 );
return;
}// Tag
if ( is_tag() ) {
//control the numbers of post displayed/listed (eg here 10)
$query->set( 'posts_per_page', 10 );
return;
}
}
add_action( 'pre_get_posts', 'post_per_page_control' );

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector