Showing subcategories on WordPress category pages

Gauloran

Kıdemli Moderatör
7 Tem 2013
8,094
585
local
Show the subcategories for a given category on it’s category page. Basically you need to check whether there are any children, and if there are, list the categories with the current category as a parent or grandparent. The following code does just that:

Kod:
if (is_category()) {
  $this_category = get_category($cat);
  if (get_category_children($this_category->cat_ID) != "") {
    echo "<h1>Subcategories</h1>";
    echo "<ul>";
    wp_list_categories('orderby=id&show_count=0&title_li=
&use_desc_for_title=1&child_of='.$this_category->cat_ID);
    echo "</ul>";
  }
}

 

Eagleweb

Kıdemli Üye
8 May 2021
2,120
1,151
localhost/e8
Show the subcategories for a given category on its category page. Basically you need to check whether there are any children, and if there are, list the categories with the current category as a parent or grandparent. The following code does just that:

Kod:
if (is_category()) {[/SIZE][/FONT][/CENTER][/SIZE][/FONT][/CENTER]
[FONT=Century Gothic][SIZE=3][CENTER][FONT=Century Gothic][SIZE=3][CENTER]  $this_category = get_category($cat);
  if (get_category_children($this_category->cat_ID) != "") {
    echo "<h1>Subcategories</h1>";
    echo "<ul>";
    wp_list_categories('orderby=id&show_count=0&title_li=
&use_desc_for_title=1&child_of='.$this_category->cat_ID);
    echo "</ul>";
  }
}



Hi
Thank You For info :)
 
Üst

Turkhackteam.org internet sitesi 5651 sayılı kanun’un 2. maddesinin 1. fıkrasının m) bendi ile aynı kanunun 5. maddesi kapsamında "Yer Sağlayıcı" konumundadır. İçerikler ön onay olmaksızın tamamen kullanıcılar tarafından oluşturulmaktadır. Turkhackteam.org; Yer sağlayıcı olarak, kullanıcılar tarafından oluşturulan içeriği ya da hukuka aykırı paylaşımı kontrol etmekle ya da araştırmakla yükümlü değildir. Türkhackteam saldırı timleri Türk sitelerine hiçbir zararlı faaliyette bulunmaz. Türkhackteam üyelerinin yaptığı bireysel hack faaliyetlerinden Türkhackteam sorumlu değildir. Sitelerinize Türkhackteam ismi kullanılarak hack faaliyetinde bulunulursa, site-sunucu erişim loglarından bu faaliyeti gerçekleştiren ip adresini tespit edip diğer kanıtlarla birlikte savcılığa suç duyurusunda bulununuz.