开发者

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');
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜