如何将HTML静态导航转换为WordPress导航?

时间:2018-01-03 23:43:59

标签: php html css wordpress

我目前正在将静态html网站转换为wordpress,我在导航工作方面遇到了麻烦......我完全迷失了。我觉得我错过了一些非常明显的东西。 (我还是很陌生)

这是我的代码; (我的html和wordpress都在header.php中,我知道一旦它工作就可以摆脱我的HTML)

<?php
?>
<!doctype html>
<html <?php language_attributes(); ?>>
<head>
    <meta charset="<?php bloginfo( 'charset' ); ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="profile" href="http://gmpg.org/xfn/11">

        <!-- Bootstrap core CSS -->
    <link href="<?php bloginfo('template_directory');?>/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="<?php bloginfo('template_directory');?>/style.css" rel="stylesheet">

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

    <?php wp_head(); ?>
</head>

<body <?php body_class(); ?>>
 <header>
      <!-- Navigation -->
    <nav class="navbar navbar-expand-lg navbar-dark">
      <div class="container">
        <a class="navbar-brand" href="index.html">Waire<span class="full-stop">.</span></a>
        <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
          <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarResponsive">
          <ul class="navbar-nav ml-auto">
            <li class="nav-item">
              <a class="nav-link" href="about.html">Articles</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="food.html">Food</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="contact.html">Events</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="#"><i class="fa fa-user" aria-hidden="true"></i></a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="#"><i class="fa fa-search" aria-hidden="true"></i></a>
            </li>

            <!---
            <li class="nav-item">
              <form action="" class="search-form">
                <div class="form-group has-feedback">
                <label for="search" class="sr-only">Search</label>
                <input type="text" class="form-control" name="search" id="search" placeholder="search">
                  <span class="glyphicon glyphicon-search form-control-feedback"></span>
              </div>
            </form>
            </li>-->
          </ul>
        </div>
      </div>
    </nav>
      <div id="carouselExampleIndicators" class="carousel carousel-header slide" data-ride="carousel">
        <ol class="carousel-indicators">
          <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
          <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
          <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
        </ol>
        <div class="carousel-inner" role="listbox">
          <!-- Slide One - Set the background image for this slide in the line below -->
          <h3 class="header-title">Leeds<span class="full-stop">.</span></h3>
          <div class="weather"><img src="<?php echo get_bloginfo('template_url')?>/imgs/weather.png" alt="weather" height="86" width="483"></div>
          <div class="carousel-item carousel-item-height active" style="background-image: url('<?php echo get_bloginfo('template_url')?>/imgs/header1.jpg')">
            <div class="carousel-caption d-none d-md-block">

            </div>
          </div>
          <!-- Slide Two - Set the background image for this slide in the line below -->
          <div class="carousel-item carousel-item-height" style="background-image: url('<?php echo get_bloginfo('template_url')?>/imgs/header1.2.jpg')">
            <div class="carousel-caption d-none d-md-block">
            </div>
          </div>
          <!-- Slide Three - Set the background image for this slide in the line below -->
          <div class="carousel-item carousel-item-height" style="background-image: url('<?php echo get_bloginfo('template_url')?>/imgs/header1.3.jpg')">
            <div class="carousel-caption d-none d-md-block">
            </div>
          </div>
        </div>
        <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
          <span class="carousel-control-prev-icon" aria-hidden="true"></span>
          <span class="sr-only">Previous</span>
        </a>
        <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
          <span class="carousel-control-next-icon" aria-hidden="true"></span>
          <span class="sr-only">Next</span>
        </a>
      </div>
    </header>

    <nav id="site-navigation" class="main-navigation navbar navbar-expand-lg navbar-dark">
      <button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false"><?php esc_html_e( 'Primary Menu', 'tender-loving-gut' ); ?></button>
       <div class="container">
        <?php
        wp_nav_menu( array(
          'theme_location' => 'menu-1',
          'menu_id'        => 'primary-menu',
        ) );
      ?>
    </div>
    </nav><!-- #site-navigation -->

    <!-- Bootstrap core JavaScript -->
    <script src="<?php bloginfo('template_directory');?>/js/main.js"></script>
    <script src="<?php bloginfo('template_directory');?>/vendor/jquery/jquery.min.js"></script>
    <script src="<?php bloginfo('template_directory');?>/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
    <script src="<?php bloginfo('template_directory');?>/http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

    <div id="content" class="site-content">

0 个答案:

没有答案