0
votes

I have this Html template that i am trying to convert to wordpress theme, I have converted it but i am trying to make the theme fetch my wordpress site menu instead of the menu that came with the template, i tried and was able to get the menu but it is not showing how it is supposed to show, and i have tried styling it but its not working, but when i use the template menu it will show normally but if i switch to use the wordpress site menu, it will still not show properly

this is My Header.php

<!DOCTYPE html>
<html <?php language_attributes(); ?> lang="en">
<head>
    <meta charset="<?php bloginfo( 'charset' ); ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>My First Theme</title>

    <!-- Bootstrap Core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet" type="text/css">

    <!-- Fonts -->
    <link href="font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href="css/animate.css" rel="stylesheet" />
    <!-- Theme CSS -->
    <link href="css/style.css" rel="stylesheet">
    <link href="color/default.css" rel="stylesheet">
<?php wp_head(); ?>
</head>

<body <?php body_class(); ?> id="page-top" data-spy="scroll" data-target=".navbar-custom">
    <!-- Preloader -->
    <div id="preloader">
      <div id="load"></div>
    </div>

    <nav class="navbar navbar-custom navbar-fixed-top" role="navigation">
        <div class="container">
            <div class="navbar-header page-scroll">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-main-collapse">
                    <i class="fa fa-bars"></i>
                </button>
                <a class="navbar-brand" href="index.html">
                    <h1>My Theme</h1>
                </a>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse navbar-right navbar-main-collapse">
      <nav class="site-nav">


        <?php
        $args = array(
            'theme_location' => 'primary'
        );

        ?>
        <?php wp_nav_menu( $args ); ?>

        </nav>
      <ul class="nav navbar-nav">


      </ul>

            </div>
            <!-- /.navbar-collapse -->
        </div>
        <!-- /.container -->
    </nav>

and this is function.php

<?php

function mytheme_scripts(){
    wp_enqueue_style('bootstrap.min', get_template_directory_uri().'/css/bootstrap.min.css', array(),null,'all');
    wp_enqueue_style('font-awesome.min', get_template_directory_uri().'/font-awesome/css/font-awesome.min.css', array(),null,'all');
    wp_enqueue_style('animate', get_template_directory_uri().'/css/animate.css', array(),null,'all');
    wp_enqueue_style('style', get_template_directory_uri().'/css/style.css', array(),null,'all');
    wp_enqueue_style('default', get_template_directory_uri().'/color/default.css', array(),null,'all');

    wp_enqueue_script('jquery.min', get_template_directory_uri().'/js/jquery.min.js', array(),null,'false');
    wp_enqueue_script('bootstrap.min', get_template_directory_uri().'/js/bootstrap.min.js', array(),null,'false');
    wp_enqueue_script('jquery.easing.min', get_template_directory_uri().'/js/jquery.easing.min.js', array(),null,'false');
    wp_enqueue_script('jquery.scrollTo', get_template_directory_uri().'/js/jquery.scrollTo.js', array(),null,'false');
    wp_enqueue_script('wow.min', get_template_directory_uri().'/js/wow.min.js', array(),null,'false');
    wp_enqueue_script('custom', get_template_directory_uri().'/js/custom.js', array(),null,'false');
}

add_action('wp_enqueue_scripts','mytheme_scripts');

// Navigation Menus
register_nav_menus(array(
    'primary' => __( 'Primary Menu'),
));
?>

this is how the template looks enter image description here

but this is how my wordpress theme looks after fetching the wordpress menu enter image description here

i tried to style it but it did not work, this is the css i tried to use

//Navigation Menus
.site-nav ul {
    margin: 0;
    padding: 0;

}

.site-nav ul:before, .site-nav ul:after { content: ""; display: table; }
.site-nav ul:after {clear: both; }
.site-nav ul { *zoom: 1; }

.site-nav ul li {
    list-style: none;
    float: left;
}
1

1 Answers

0
votes

You need to add a parameter to "wp_nav_menu" function.

'menu_class' => 'nav navbar-nav',

With this parameter the menu take the base styles of bootstrap. You can learn more about wp_nav_menu parameters at this link: https://developer.wordpress.org/reference/functions/wp_nav_menu/