Tag Archives: wordpress

Tech9 Theme Mods – WP3 Custom Menus

Hello world,

My very first blog post is about the theme I currently am using. Kudos goes to Milo317 for putting it together. It is a stunning professional looking design that I think is amazing. Unfortunately, there were a few things missing such as the pages with comments, tags in posts, and most importantly – WP3 custom menus. Fortunately, I was able to add them in ;-).

I have already sent these fixes to the author, so I am sure they will make them upstream, but for reference, you need to make the following code changes to add custom menus.

Replace the inc/nav.php file with the following:

1
2
3
<?php
    custom_nav();
?>

Add this to your functions.php file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function add_custom_menus() {
    register_nav_menus(
        array(
            'main_nav' => 'The Main Menu',
        )
    );
}
add_action( 'init', 'add_custom_menus' );
function custom_nav() {
    if ( function_exists( 'wp_nav_menu' ) )
        wp_nav_menu( 'menu=main_nav&container=&menu_id=nav&fallback_cb=nav_fallback' );
    else
        nav_fallback();
}
 
function nav_fallback() {
?>
<ul id="nav">
<li class="<?php if ( is_home() or is_archive() or is_paged() or is_search() or (function_exists('is_tag') and is_tag()) ) { ?>current_page_item<?php } else { ?>page_item<?php } ?>"></li>
<?php
 
    wp_list_pages('title_li=&depth=4&exclude=183657917,183658042,183657912,183657914,183657918&sort_column=menu_order');
    echo "</ul>";
}

Now you have custom menus… Stay tune for instructions on other modifications including the very own syntax highlighting.

Jonathan