$10
Dynamic Categories in 3.0 Navigation
Here is my code in the functions.php that simply throws out the menu -
function childtheme_menu() { ?>
<div id="access">
<div class="skip-link"><a href="#content" title="<?php _e('Skip navigation to the content', 'thematic'); ?>">
<?php _e('Skip to content', 'thematic'); ?></a></div>
<?php wp_nav_menu( 'sort_column=menu_order&container_class=menu&menu_class=sf-menu&depth=3' ); ?>
</div>
<!-- #access -->
<?php }
add_action('thematic_belowheader','childtheme_menu',9);
Chris | 09/01/10 at 1:02pm
| Edit
(3) Possible Answers Submitted...
-

Last edited:
09/01/10
1:57pmenodekciw says:try this:
function childtheme_menu() { ?>
<div id="access">
<div class="skip-link"><a href="#content" title="<?php _e('Skip navigation to the content', 'thematic'); ?>">
<?php _e('Skip to content', 'thematic'); ?></a></div>
<?php wp_nav_menu( 'sort_column=menu_order&container_class=menu&menu_class=sf-menu&depth=3' ); ?>
<?php wp_list_categories('title_li='); ?>
</div>
<!-- #access -->
<?php }
add_action('thematic_belowheader','childtheme_menu',9);- 09/01/10 1:13pm
Chris says:I've already tried this but it doesn't work because the wp_nav_menu encapsulates the menu in the proper div tags - this places it outside of that. What I need is the dynamic categories to be shown INSIDE the output produced by wp_nav_menu
- 09/01/10 1:17pm
enodekciw says:ok, so it wraps the menu. let's unwrap it ;)
function childtheme_menu() { ?>
<div id="access">
<div class="skip-link"><a href="#content" title="<?php _e('Skip navigation to the content', 'thematic'); ?>">
<?php _e('Skip to content', 'thematic'); ?></a></div>
<?php wp_nav_menu( 'sort_column=menu_order&container=&container_class=&menu_class=sf-menu&depth=3' ); ?>
<?php wp_list_categories('title_li='); ?>
</div>
<!-- #access -->
<?php }
add_action('thematic_belowheader','childtheme_menu',9); - 09/01/10 1:32pm
enodekciw says:now it should generate plaind list items without the <ul></ul>. so just those two functions into <ul id="menu"></ul> or something and you should be good to go ;)
- 09/01/10 1:52pm
enodekciw says:oh, now I get your problem. you can try to solve it like this:
pass echo=false into wp_nav_menu().
use some variable to get the markup, something like this $menu = wp_nav_menu();
now you have $menu var which hold your menu markup, so now you can write some functions to manipulate it like you want, for example, you can write a function to extract list items, or just to get rid of the tags you dont need.
combine it with wp_list_categories();, wrap everything into <ul></ul> - now you have your menu working ;)
I would like to help and write the full code for you, but I'm leaving so soon that I won't be able to do that. But I will be happy if I got you on the way ;) - 09/01/10 1:55pm
Chris says:enodekciw - you got me on my way. I had been playing around with this before i posted the question but wasn't able to get it working. Thanks to your help I was able to, and added all the nested ul / li mark-up which made it work just fine. Here is my final code:
function childtheme_menu() { ?>
<div id="access">
<div class="skip-link"><a href="#content" title="<?php _e('Skip navigation to the content', 'thematic'); ?>">
<?php _e('Skip to content', 'thematic'); ?></a></div>
<?php wp_nav_menu( 'sort_column=menu_order&container_class=menu&menu_class=sf-menu&depth=3' ); ?>
<div class="menu-cat">
<ul id="menu-category-nav" class="sf-menu sf-js-enabled">
<li class="menu-item" class="sf-menu"><a href="#">Categories</a>
<ul class="sub-menu"><?php wp_list_categories('title_li='); ?></ul>
</li>
</ul>
</div>
</div>
<!-- #access -->
<?php }
add_action('thematic_belowheader','childtheme_menu',9);
- 09/01/10 1:13pm
-

Last edited:
09/01/10
1:10pmTobias Nyholm says:I have created a plugin for dynamic subpages: http://www.wordpress.org/extend/plugins/dynamic-subpages/
I think you can figure your problem out by watching my code.
- 09/01/10 1:14pm
Chris says:Tobias,
Looks like you are creating an entirely new menu system. Do you know how to make this function within the WP 3.0.1 menu system?
- 09/01/10 1:14pm
-

Last edited:
09/01/10
1:57pmMaor Barazany says:The simple and short answer is that you can't do dynamic menus (categories or pages) with the new wp_nav_menu functions.
You have to use either the nav function to let the end user manually decide what to have on the menu, or use the
function that was suggested here.wp_list_categories
- 09/01/10 1:55pm
Chris says:Thanks for this Maor.
- 09/01/10 1:55pm
This question has expired.
Current status of this question: Completed





