簡體   English   中英

在此PHP中,我應將類別ID放在哪里以返回某個類別的博客條目?

[英]In this PHP, where do I put the category ID in order to return blog entries of a category?

這來自以WordPress為主題的PHP腳本。 我需要返回ID為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);

?>

如果只想顯示類別ID為20的條目,則將所有代碼替換為:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM