Link to home
Start Free TrialLog in
Avatar of rajoo_sharma
rajoo_sharma

asked on

WordPress - how to display custom menu in a theme?

Hi,
I'm using WordPress 3.0.5, I added a menu called "Top Menu" through WP-Admin-> Appearance->Menus
I added some pages to it, how can I display it in the header of my theme? Is there any function to call such custom menus?

Thanks
Avatar of jeremyjared74
jeremyjared74
Flag of United States of America image

If the WP Nav Menu is active in your current theme, just add this to your header.php file where you want the menu:
<?php wp_nav_menu( array( 'sort_column' => 'menu_order', 'container_class' => 'menu-header' ) ); ?>

Open in new window


If it isn't activated try adding this just before the closing ?> PHP tag in the functions.php file along with the code above for the header.php:
add_theme_support( 'menus' );

Open in new window

Avatar of rajoo_sharma
rajoo_sharma

ASKER

Hi,
Thanks for the reply. I'm new to WordPress so my queries could be really stupid :)

1. I've two custom menus "Top Menu" and "Bottom Menu"
2. I added the following code in the header.php
<?php wp_nav_menu( array( 'sort_column' => 'menu_order', 'container_class' => 'menu-header' ) ); ?>

Open in new window

3. It always shows me the Top Menu, how can I get a menu by name or ID?
4. Adding or removing this piece of code
add_theme_support( 'menus' );

Open in new window

at the end of the functions.php makes no difference. The menu always appears.

Regards
ASKER CERTIFIED SOLUTION
Avatar of jeremyjared74
jeremyjared74
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

Thanks for such a great detailed explanation. I could achieve what I wanted.

I've one more query related to displaying select Page's/Post's teaser in a block using admin. How can I accomplish this? e.g. a video on a home page or teaser of about us page on home page in a block / region.

Should I post another question for this?

Regards
You could use the featured image feature to achieve this. Here is a link to a good source. Let me know if you have any questions.

http://ponderwell.net/2011/02/wordpress-featured-images-and-custom-thumbnail-sizes/
Thanks again,
I'll surely post questions as I've just started using WordPress :).

Regards
Thank you for such an accurate solution.
You're welcome. Let me know if you run into any problems with the featured image hack.