In this PHP, where do I put the category ID in order to return blog entries of a category?
This comes from a PHP script in a theme of WordPress. I need to return blog entries 开发者_StackOverflowwith category that has an ID of 20.
<?php /* make a new query for grid items (in single page) */
$new_query_arg = 'paged='.$paged;
// use this code if you want filter items by category.
$arr_catID = array();
foreach( get_the_category() as $cat) $arr_catID[] = $cat->cat_ID;
if ( count($arr_catID) ) $new_query_arg .= '&cat=' . join(',', $arr_catID);
query_posts($new_query_arg);
?>
If you want to only display entries with category ID 20, then replace all the code with:
query_posts('paged='.$paged.'&cat=20');
精彩评论