开发者

Wordpress show sub menu items on index page

I am using wordpress and on the page "sidebar.php" I have the following code:

<?php wp_list_pages('post_type=wiki&开发者_如何学Pythonamp;depth=1'); ?>

It works great but what I need to do it that what I click on a Menu item on the sidebar I need the sub items to display on the main page.

UPDATE:

What I basically need to do is to have the first level items on the left (As it currently is), and when those links are clicked then the sub items of those items will be listed on the index.php (main page).

I am using the wp-wiki plugin to display the pages as wiki pages but the actual but the list is the same, just showing as a different type:

post_type=wiki

Can anyone help please?

Thanks


<?php
   wp_list_pages('sort_column=menu_order&title_li=&child_of='.$post->ID.'&depth=0');
?>


There's several ways you can accomplish this. WordPress actually has an example of exactly what you're looking to do in the Codex. (link - the last example in that section, right above the "List subpages even if on a subpage" heading)

There's several ways to do this though - that's just one example. But that code above, you just pop into your sidebar.php file. You can also create a widget out of it. And as someone else mentioned, you can use the new menu system for WordPress (but you can indeed, make it dynamic.) But the above example in the Codex is the simplest method.

Actually, an easier method would be just to list all subpages and use CSS to hide and show the child items based on what page you're on. The classes are already set up for you. Just view your source code and you can see it. So you'd do something like:

`li ul.children {display:none; }
 li.current_page ul.children { display:block; }`

and variations thereof.


What about using the new menu function in wp 3?
That way you could include your type with any sub page you want (won't be dynamic though) and then add your favorite javascript or good css to show those sub-pages.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜