$10
Add Category Descriptions to wp_nav_menu in WP 3.0
I am building this theme on WordPress 3.0, and would like to utilize the wp_nav_menu functionality, but cant seem to get it to display the category description as well.
The end goal is to do something like this - http://www.woothemes.com/demo/papercut/
Using the new menu navigation tool in wp 3 and have it display my categories, but also have it display each category description. I already have everything worked out except getting it to display the category descriptions.
Here is my current html structure for this area:
View Code
Aaron | 06/05/10 at 11:04am
| Edit
(3) Possible Answers Submitted...
-
Last edited:
06/05/10
11:47amOleg Butuzov says:can i help you? you want to show the category description? or you want to show the description of the nav_menu witch is relates to the category?
- 06/05/10 1:06pm
Aaron says:Yes to display the category descriptions.
- 06/05/10 1:22pm
Oleg Butuzov says:that's no sence. in this case you will need to amke twice more db queries for each of the menu items.you can duplicate the the category description inside to the navigation menu. if thats ok for you i can make a custom filter for your menu.
- 06/05/10 1:06pm
-

Last edited:
06/05/10
2:58pmUtkarsh Kukreti says:I was going to publish a similar tutorial in my site in a few days. Here's the modified code of it, to insert description inside em
add_filter('walker_nav_menu_start_el', 'description_in_nav_el', 10, 4);
function description_in_nav_el($item_output, $item, $depth, $args)
{
return preg_replace('/(<a .*?>)/', '$1' . "{$item->post_content}", $item_output);
}
Will produce
<a href="#">The DescriptionA Category</a>Previous versions of this answer: 06/05/10 at 1:41pm | 06/05/10 at 1:41pm | 06/05/10 at 1:42pm
- 06/05/10 2:41pm
Aaron says:For me this did not wrap the description in em tags. Also can it flip-flop the category name and the description, so that the category name comes first, and then the category description with the category description wrapped in em tags?
Thanks - 06/05/10 2:45pm
Utkarsh Kukreti says:Try http://pastebin.com/LKtDP63h
- 06/05/10 2:50pm
Aaron says:Looks good, except it does not close out the a link tag. it outputs this to the screen /a>
It's missing the '<' before the closing a link tag - 06/05/10 2:54pm
Utkarsh Kukreti says:http://pastebin.com/NVcUsTY0
- 06/05/10 2:41pm
-

Last edited:
06/05/10
1:43pm
This question has expired.
Current status of this question: Completed




