开发者

Wordpress function to display all posts without pagination with a cateogory ID of 20?

开发者 https://www.devze.com 2023-02-10 07:24 出处:网络
If this displays posts with category ID of 20 with pagination query_posts(\'paged=\'.$paged.\'&cat=20\');

If this displays posts with category ID of 20 with pagination

query_posts('paged='.$paged.'&cat=20');

how do I display all posts with category ID of 20 without pagination and without going into Dash开发者_StackOverflow中文版board -> Reading -> Blog Posts Show at Most?


I got it to work like this.

<?php
query_posts(array('cat'=>20,'posts_per_page'=>-1));
?>

This one is even better as it does not affect the original loop.

<?php $posts = new WP_Query(array('cat'=>20,'posts_per_page'=>-1)); ?>


Use get_posts instead and write your own loop.

0

精彩评论

暂无评论...
验证码 换一张
取 消