Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Tuan Le
PLUS
Tuan Le
Courses Plus Student 298 Points

Problem with Walker nav Bootstrap video

Hi everyone,I am having a problem with Walker nav menu,I'm trying to build a bootstrap drop down menu for my theme but I got this error: Fatal error: Call to undefined function wp_nav_menu() in /home/tuananhle1981/public_html/no1nailsupply.co.uk/wp-content/themes/no1nailsupply-wp/header.php on line 99 Please advice me what did I done wrong,any sugggest would be much appiercate,thank you.

3 Answers

Hi Tuan,

What version of WordPress are you using? I would have to assume right now that you are using an outdated version.

Can you post the nav_menu array?

Tuan Le
PLUS
Tuan Le
Courses Plus Student 298 Points

HI Mark and Jacob! Thank you very much for reply,I'm using Wordpress 4.6 and this is my header.php code,please have a look :
<!doctype html> <!--[if IE 9 ]><html class="ie9" lang="en"><![endif]--> <!--[if (gt IE 9)|!(IE)]><!--><html lang="en"><!--<![endif]--> <head> <title>No1 Nail Supply UK | The Leading Nails Supplier | No1 Nail Supply Charlton SE10</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> <!--meta info--> <meta name="author" content=""> <meta name="keywords" content=""> <meta name="robots" content="INDEX,FOLLOW" /> <meta name="description" content=""> <link rel="icon" type="image/ico" href="<?php echo bloginfo('template_directory'); ?>/images/fav.ico"> <!--stylesheet include--> <link rel="stylesheet" type="text/css" media="all" href="<?php echo bloginfo('template_directory'); ?>/css/bootstrap.min.css"> <link rel="stylesheet" type="text/css" media="all" href="<?php echo bloginfo('template_directory'); ?>/style.css"> <link rel="stylesheet" type="text/css" media="all" href="<?php echo bloginfo('template_directory'); ?>/css/settings.css"> <link rel="stylesheet" type="text/css" media="all" href="<?php echo bloginfo('template_directory'); ?>/css/owl.carousel.css"> <link rel="stylesheet" type="text/css" media="all" href="<?php echo bloginfo('template_directory'); ?>/css/owl.transitions.css"> <link rel="stylesheet" type="text/css" media="all" href="<?php echo bloginfo('template_directory'); ?>/css/jquery.custom-scrollbar.css">

    <!--font include-->
    <link href="<?php echo bloginfo('template_directory'); ?>/css/font-awesome.min.css" rel="stylesheet">
    <script src="<?php echo bloginfo('template_directory'); ?>/js/modernizr.js"></script>
    <?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
    <!--boxed layout-->
    <div class="wide_layout relative w_xs_auto">
        <!--[if (lt IE 9) | IE 9]>
            <div style="background:#fff;padding:8px 0 10px;">
            <div class="container" style="width:1170px;"><div class="row wrapper"><div class="clearfix" style="padding:9px 0 0;float:left;width:83%;"><i class="fa fa-exclamation-triangle scheme_color f_left m_right_10" style="font-size:25px;color:#e74c3c;"></i><b style="color:#e74c3c;">Attention! This page may not display correctly.</b> <b>You are using an outdated version of Internet Explorer. For a faster, safer browsing experience.</b></div><div class="t_align_r" style="float:left;width:16%;"><a href="http://windows.microsoft.com/en-US/internet-explorer/products/ie/home?ocid=ie6_countdown_bannercode" class="button_type_4 r_corners bg_scheme_color color_light d_inline_b t_align_c" target="_blank" style="margin-bottom:2px;">Update Now!</a></div></div></div></div>
        <![endif]-->
        <!--markup header-->
        <header role="banner" class="type_5">
            <!--header top part-->
            <section class="h_top_part">
                <div class="container">
                    <div class="row clearfix">
                        <div class="col-lg-4 col-md-4 col-sm-5 t_xs_align_c">
                            <ul class="d_inline_b horizontal_list clearfix f_size_small users_nav">
                                <li><a href="#" class="default_t_color" data-popup="#login_popup">Log in</a></li>
                                <li><a href="#" class="default_t_color">My Account</a></li>
                                <li><a href="orders_list.html" class="default_t_color">List Orders</a></li>
                                <li><a href="checkout.html" class="default_t_color">Checkout</a></li>
                            </ul>
                        </div>
                        <div class="col-lg-4 col-md-4 col-sm-2 t_align_c t_xs_align_c">
                            <p class="f_size_small">Call us toll free: <b class="color_dark">02088564499</b></p>
                        </div>
                        <div class="col-lg-4 col-md-4 col-sm-5 t_align_r t_xs_align_c">
                            <ul class="horizontal_list clearfix d_inline_b t_align_l f_size_small site_settings type_2">
                                <li class="container3d relative">
                                    <a role="button" href="#" class="color_dark" id="lang_button"><img class="d_inline_middle m_right_10" src="<?php echo bloginfo('template_directory'); ?>/images/flag_en.jpg" alt="">English</a>
                                    <ul class="dropdown_list type_2 top_arrow color_light">
                                        <li><a href="#" class="tr_delay_hover color_light"><img class="d_inline_middle" src="<?php echo bloginfo('template_directory'); ?>/images/flag_en.jpg" alt="">English</a></li>
                                        <li><a href="#" class="tr_delay_hover color_light"><img class="d_inline_middle" src="<?php echo bloginfo('template_directory'); ?>/images/flag_fr.jpg" alt="">French</a></li>
                                        <li><a href="#" class="tr_delay_hover color_light"><img class="d_inline_middle" src="<?php echo bloginfo('template_directory'); ?>/images/flag_g.jpg" alt="">German</a></li>
                                        <li><a href="#" class="tr_delay_hover color_light"><img class="d_inline_middle" src="<?php echo bloginfo('template_directory'); ?>/images/flag_i.jpg" alt="">Italian</a></li>
                                        <li><a href="#" class="tr_delay_hover color_light"><img class="d_inline_middle" src="<?php echo bloginfo('template_directory'); ?>/images/flag_s.jpg" alt="">Spanish</a></li>
                                    </ul>
                                </li>
                                <li class="m_left_20 relative container3d">
                                    <a role="button" href="#" class="color_dark" id="currency_button"><span class="scheme_color">£</span> Pound </a>
                                    <ul class="dropdown_list type_2 top_arrow color_light">
                                        <li><a href="#" class="tr_delay_hover color_light"><span class="scheme_color">$</span> US Dollar</a></li>
                                        <li><a href="#" class="tr_delay_hover color_light"><span class="scheme_color">&#8364;</span> Euro</a></li>
                                        <li><a href="#" class="tr_delay_hover color_light"><span class="scheme_color">&#163;</span> Pound</a></li>
                                    </ul>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </section>
            <!--header bottom part-->
            <section class="h_bot_part">
            <div class="menu_wrap">
                    <div class="container">
                        <div class="clearfix row">
                            <div class="col-lg-2 t_md_align_c m_md_bottom_15">
                                <a href="index.html" class="logo d_md_inline_b">
                                    <img src="<?php echo bloginfo('template_directory'); ?>/images/no1supply-logo.svg" alt="no1logo">
                                </a>
                            </div>
                            <div class="col-lg-10 clearfix t_sm_align_c">
                                <div class="clearfix t_sm_align_l f_left f_sm_none relative s_form_wrap m_sm_bottom_15 p_xs_hr_0 m_xs_bottom_5">
                                    <!--button for responsive menu-->
                                    <button id="menu_button" class="r_corners centered_db d_none tr_all_hover d_xs_block m_xs_bottom_5">
                                        <span class="centered_db r_corners"></span>
                                        <span class="centered_db r_corners"></span>
                                        <span class="centered_db r_corners"></span>
                                    </button>


                                    <!--main menu-->
                                    <nav role="navigation" class="f_left f_xs_none d_xs_none m_right_35 m_md_right_30 m_sm_right_0">
                                          <?php
                                                wp_nav_menu( array(
                                                    'menu'              => 'primary',
                                                    'theme_location'    => 'primary',
                                                    'depth'             => 2,
                                                    'menu_class'        => 'nav navbar-nav',
                                                    'fallback_cb'       => 'wp_bootstrap_navwalker::fallback',
                                                    'walker'            => new wp_bootstrap_navwalker())
                                                );
                                             ?>

                                        </nav>
                                    <button class="f_right search_button tr_all_hover f_xs_none d_xs_none">
                                        <i class="fa fa-search"></i>
                                    </button>
                                    <!--search form-->
                                    <div class="searchform_wrap type_2 bg_tr tf_xs_none tr_all_hover w_inherit">
                                        <div class="container vc_child h_inherit relative w_inherit">
                                            <form role="search" class="d_inline_middle full_width">
                                                <input type="text" name="search" placeholder="Type text and hit enter" class="f_size_large p_hr_0">
                                            </form>
                                            <button class="close_search_form tr_all_hover d_xs_none color_dark">
                                                <i class="fa fa-times"></i>
                                            </button>
                                        </div>
                                    </div>
                                </div>
                                <ul class="f_right horizontal_list d_sm_inline_b f_sm_none clearfix t_align_l site_settings">
                                    <!--like-->


                                    <!--shopping cart-->

                                </ul>
                            </div>
                        </div>
                    </div>
                    <hr class="divider_type_6">
                </div>
            </section>
        </header>

and I got these code in functions.php:

// Register Custom Navigation Walker require_once('wp_bootstrap_navwalker.php');

// Register Custom Navigation Walker function ts_theme_setup(){ register_nav_menus(array( 'primary-menu' => __( 'Primary Menu', 'theme_star_ecomerce' ),

));

}

add_action('after_setup_theme', 'ts_theme_setup'); and finally I also have wp_bootstrap_navwalker.php file in my theme directory.Please let me know what did I done wrong I am grateful.Thank again guys.