[英]Custom category pagination Wordpress
我在WordPress的自定义模板页面上有一个自定义循环,该循环显示来自特定类别的帖子。 这一切都很好,显示了我需要的一切,但是最终我需要添加一些分页。 由于这是一个自定义循环,因此本地WP“博客页面最多显示”似乎不起作用。 有没有一种方法可以向我的自定义循环添加分页?
<?php
// add journal posts to the journal page
query_posts( array ( 'category_name' => 'journals', 'posts_per_page' => -1 ) );
?>
<?php
// The Loop
while ( have_posts() ) : the_post();
echo '<div class="journal-posts">';
echo '<h2 class="entry-title">';
echo '<div><a href="'. esc_url( get_permalink() ) . '">' . sprintf(__( get_the_title() )) . '</a> <img src="http://localhost/website.co.uk/wp-content/themes/themename/images/icons/icon.png" alt="Icon Stuff"/></div>';
echo '</h2>';
echo '<span class="entry-meta">Posted on ';
echo '<span class="date-link">';
the_date();
echo '</span>';
echo ' by ';
echo '<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>';
echo '</span>';
the_content();
echo '</div>';
endwhile; ?>
<?php
// Reset Query
wp_reset_query();
?>
我为此网站调用了三个单独的类别,因此为什么我需要在每个页面上都有这个自定义循环。 除非有更好的方法呢?
提前致谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.