#php #wordpress #pagination
#php #wordpress #разбивка на страницы
Вопрос:
Итак, моя ссылка для показа старых сообщений не отображается на моей главной странице блога http://surechamp.com/blog / он отлично отображается в моем archive.php так что я не совсем понимаю, почему это не работает с index.php . Я использую подчеркивания в качестве своей базовой темы для работы. Это мой код:
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php
/* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( 'content', get_post_format() );
?>
<?php endwhile; ?>
<?php _s_paging_nav(); ?>
<?php else : ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>
Ответ №1:
Обычно я запускаю навигацию по страницам вне цикла и проверяю, будет ли отображаться предыдущая или следующая ссылка:
<?php if ( $wp_query->max_num_pages > 1 ) : ?>
<?php if($wp_query->get('paged') || $wp_query->get('paged') > 1): ?>
<a class="loadPrev" href="<?php previous_posts(); ?>">prev</a>
<?php endif; ?>
<?php if ($next_url = next_posts($wp_query->max_num_pages, false)): ?>
<a class="loadNext" href="<?php echo $next_url; ?>">next</a>
<?php endif;?>
<?php endif; ?>