WordPress navigation wont appear with wp_head
so im building a custom theme and ive got stuck on the navigation
if i use wp_head(); it loads bootstrap and my custom style sheet but not the navigation if i use get_header(); it loads the navigation but not bootstrap or my custom style sheet
here is my functions.php
function register_navwalker(){
require_once get_template_directory() . '/inc/class-wp-bootstrap-navwalker.php';
}
add_action( 'after_setup_theme', 'register_navwalker' );
function wpbootstrap_enqueue_styles() {
wp_enqueue_style( 'bootstrap', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css' );
wp_enqueue_style( 'my-style', get_template_directory_uri() . '/style.css');
wp_enqueue_script('bootstrap-js', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js', array('jquery'), NULL, true);
}
add_action('wp_enqueue_scripts', 'wpbootstrap_enqueue_styles');
register_nav_menus(
array(
'main_menu'='Main Menu',
)
);
here is my navigation code in header.php
nav class=navbar navbar-expand-md navbar-light bg-light role=navigation
div class=container
button class=navbar-toggler type=button data-toggle=collapse data-target=#bs-example-navbar-collapse-1 aria-controls=bs-example-navbar-collapse-1 aria-expanded=false aria-label=?php esc_attr_e( 'Toggle navigation', 'your-theme-slug' ); ?
span class=navbar-toggler-icon/span
/button
a class=navbar-brand href=#Navbar/a
?php
wp_nav_menu( array(
'theme_location' = 'main_menu',
'depth' = 2,
'container' = 'div',
'container_class' = 'collapse navbar-collapse',
'container_id' = 'bs-example-navbar-collapse-1',
'menu_class' = 'nav navbar-nav',
'fallback_cb' = 'WP_Bootstrap_Navwalker::fallback',
'walker' = new WP_Bootstrap_Navwalker(),
) );
?
/div
Topic twitter-bootstrap navigation php theme-development Wordpress
Category Web