开发者

Wordpress: list category tree only from one category

I got a lot of categories on my page, and made them hierarchical, something 开发者_运维技巧like this:

News
Fun
...
Somestuff
- child of somestuff
- - grandchild of somestuff
- - 2nd grandchild of somestuff
- 2nd child of somestuff

Now i want to create some navigation only for "somestuff" category, that only displays the child and grandchild elements, exactly like this:

<ul>

<li>child of somestuff

<ul>

<li>grandchild of somestuff</li>

<li>2nd grandchild of somestuff</li>

</ul>

</li>

<li> ... and so on </li>

</ul>

What i tryd first, is this: (135 => somestuff)

$args = array(

'show_option_all' => false,

'orderby' => 'name',

'order' => 'ASC',

'style' => 'list',

'hierarchical' => true,

'title_li' => false,

'depth' => 5,

'hide_empty' => false,

'child_of' => '135'

);

wp_list_categories( $args );

However this won't display the "grand child" elements. I need some help with this. ~


And yes this works, thanks Dogbert, however the reason why this didn't work for me the first time is this:

http://wordpress.org/support/topic/child-category-missing-from-admin-list-but-its-there

After going to phpmyadmin, and playing with fix table a bit, it works again in the admin menu, and on the page... Annoying bug here, and no real solution?! :(


<?php 
    wp_list_categories( array(
   'child_of'            => 135, //your category id
        'current_category'    => 0,
        'depth'               => 0,
        'echo'                => 1,
        'hide_empty'          => 1,
        'hide_title_if_empty' => false,
        'hierarchical'        => true,
        'order'               => 'DESC',
        'orderby'             => 'count',
        'show_count'          => 0,
        'show_option_none'    => __( 'No categories' ),
        'style'               => 'list',
        'taxonomy'            => 'category',
        'title_li'            => 0,
        'use_desc_for_title'  => 0,
    ) ); 
?> 
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜