2010-10-26 35 views

回答

1

您可以通過使用get_categories()功能做到這一點。這將返回所有類別的數組。有它法典文章在這裏:http://codex.wordpress.org/Function_Reference/get_categories

$categories = get_categories(); 
$parent_id = 25; //the id of the parent category 

foreach ($categories as $category) { 
    if ($category->parent == $parent_id) { 
     echo "'" . $category->name . "'," 
    } 
} 

這應該工作 - 讓我知道你如何去。其他人可能有更好的解決方案,但我已經使用了類似的解決方案,並且沒有任何問題。

0

你可以擴展Walker_Category類,併爲它分配到wp_list_categories($args);$args中的walker屬性。

通過這樣做,您就可以重寫鏈接的呈現方式。在你的情況下,你可能只需複製Walker_Category中的代碼並刪除包含類別名稱的部分(<a>)。

也許有一種更簡單的方法;我不知道 - 我是WP n00b。

下面是一個例子,我被挖到你:

http://www.wprecipes.com/how-to-modify-lists-like-categories-and-blogroll-in-wordpress