index.php没有链接到single.php单页帖子

时间:2018-01-09 19:18:56

标签: php wordpress templates

大家好我正在研究wordpress主题/模板,点击index.html中的博客文章标题时遇到问题。它会将我重定向到地址栏上的正确链接,但是single.php没有显示任何内容。我不确定该页面是否被调用或实际发生了什么。如果你可以加权你的2cet,感谢这里是wordpress博客的链接:http://pctechtips.org/testblog 的index.php

<?php get_header(); ?>
    <!-- jumbotron -->
      <div class="jumbotron jumbotron-fluid">
        <div class="container">
          <h1 class="display-4"><?php bloginfo('name'); ?></h1>
          <p class="lead"><?php bloginfo('description'); ?></p>
        </div>
      </div>

    <!-- /jumbotron -->

    <!-- Page Content -->
    <div class="container">

      <div class="row">

        <!-- Blog Entries Column -->
        <div class="col-md-8">

         <?php if(have_posts()) : ?>
            <?php while(have_posts()) : the_post(); ?>

          <!-- Blog Post -->
          <div class="mb-4">
            <div class="card-body">
                <a href="<?php the_permalink(); ?>">
                    <h2 class="card-title"><?php the_title(); ?></h2>
                </a>
                <p class="blog-post-meta">
                    <?php echo Date('M d, Y'); ?> by <a href="<?php echo get_author_posts_url(get_the_author_meta('ID')); ?>"><?php the_author(); ?></a>
                </p>
                <!-- feature image -->
                <?php if(has_post_thumbnail()) : ?>
                <div class="post-thumb">
                    <?php the_post_thumbnail(); ?>
                </div>
            <?php endif; ?>
              <p class="card-text"><?php the_excerpt(); ?></p>
            </div>
          </div>

      <?php endwhile; ?>
      <?php else : ?>
          <p><?php __('No Post Found!'); ?></p>
      <?php endif; ?>

          <!-- Pagination -->
          <ul class="pagination justify-content-center mb-4">
            <li class="page-item">
              <a class="page-link" href="#">&larr; Older</a>
            </li>
            <li class="page-item disabled">
              <a class="page-link" href="#">Newer &rarr;</a>
            </li>
          </ul>

        </div>

        <!-- Sidebar Widgets Column -->
        <div class="col-md-4">

          <!-- Search Widget -->
          <div class="card my-4">
            <h5 class="card-header">Search</h5>
            <div class="card-body">
              <div class="input-group">
                <input type="text" class="form-control" placeholder="Search for...">
                <span class="input-group-btn">
                  <button class="btn btn-secondary" type="button">Go!</button>
                </span>
              </div>
            </div>
          </div>

          <!-- Categories Widget -->
          <div class="card my-4">
            <h5 class="card-header">Categories</h5>
            <div class="card-body">
              <div class="row">
                <div class="col-lg-6">
                  <ul class="list-unstyled mb-0">
                    <li>
                      <a href="#">Web Design</a>
                    </li>
                    <li>
                      <a href="#">HTML</a>
                    </li>
                    <li>
                      <a href="#">Freebies</a>
                    </li>
                  </ul>
                </div>
                <div class="col-lg-6">
                  <ul class="list-unstyled mb-0">
                    <li>
                      <a href="#">JavaScript</a>
                    </li>
                    <li>
                      <a href="#">CSS</a>
                    </li>
                    <li>
                      <a href="#">Tutorials</a>
                    </li>
                  </ul>
                </div>
              </div>
            </div>
          </div>

          <!-- Side Widget -->
          <div class="card my-4">
            <h5 class="card-header">Side Widget</h5>
            <div class="card-body">
              You can put anything you want inside of these side widgets. They are easy to use, and feature the new Bootstrap 4 card containers!
            </div>
          </div>

        </div>

      </div>
      <!-- /.row -->

    </div>
    <!-- /.container -->
    <?php get_footer(); ?>

single.php中

<?php get_header(); ?>

    <!-- jumbotron -->
      <div class="jumbotron jumbotron-fluid">
        <div class="container">
          <h1 class="display-4"><?php bloginfo('name'); ?></h1>
          <p class="lead"><?php bloginfo('description'); ?></p>
        </div>
      </div>
    <!-- /jumbotron -->

    <!-- Page Content -->
    <div class="container">

      <div class="row">
        <!-- Blog Entries Column -->
        <div class="blog-post col-md-8"> 

         <?php if(have_posts()) : ?>
            <?php while(have_posts()) : the_post(); ?>

          <!-- Blog Post -->
          <div class="blog-post-title mb-4">            
                    <h2 class="card-title"><?php the_title(); ?></h2>
                <p class="blog-post-meta">
                    <?php echo Date('M d, Y'); ?> by <a href="<?php echo get_author_posts_url(get_the_author_meta('ID')); ?>"><?php the_author(); ?></a>
                </p> 
                <!-- feature image -->
                <?php if(has_post_thumbnail()) : ?>
                <div class="post-thumb">
                    <?php the_post_thumbnail(); ?>
                </div>
            <?php endif; ?>
              <p class="card-text"><?php the_content(); ?></p> 
              <hr>
              <!-- comments -->
              <?php comments_templates(); ?>
          </div>

      <?php endwhile; ?>
      <?php else : ?>
          <p><?php __('No Post Found!'); ?></p>
      <?php endif; ?>

          <!-- Pagination -->
          <ul class="pagination justify-content-center mb-4">
            <li class="page-item">
              <a class="page-link" href="#">&larr; Older</a>
            </li>
            <li class="page-item disabled">
              <a class="page-link" href="#">Newer &rarr;</a>
            </li>
          </ul>

        </div>

        <!-- Sidebar Widgets Column -->
        <div class="col-md-4">

          <!-- Search Widget -->
          <div class="card my-4">
            <h5 class="card-header">Search</h5>
            <div class="card-body">
              <div class="input-group">
                <input type="text" class="form-control" placeholder="Search for...">
                <span class="input-group-btn">
                  <button class="btn btn-secondary" type="button">Go!</button>
                </span>
              </div>
            </div>
          </div>

          <!-- Categories Widget -->
          <div class="card my-4">
            <h5 class="card-header">Categories</h5>
            <div class="card-body">
              <div class="row">
                <div class="col-lg-6">
                  <ul class="list-unstyled mb-0">
                    <li>
                      <a href="#">Web Design</a>
                    </li>
                    <li>
                      <a href="#">HTML</a>
                    </li>
                    <li>
                      <a href="#">Freebies</a>
                    </li>
                  </ul>
                </div>
                <div class="col-lg-6">
                  <ul class="list-unstyled mb-0">
                    <li>
                      <a href="#">JavaScript</a>
                    </li>
                    <li>
                      <a href="#">CSS</a>
                    </li>
                    <li>
                      <a href="#">Tutorials</a>
                    </li>
                  </ul>
                </div>
              </div>
            </div>
          </div>

          <!-- Side Widget -->
          <div class="card my-4">
            <h5 class="card-header">Side Widget</h5>
            <div class="card-body">
              You can put anything you want inside of these side widgets. They are easy to use, and feature the new Bootstrap 4 card containers!
            </div>
          </div>

        </div>

      </div>
      <!-- /.row -->

    </div>
    <!-- /.container -->
    <?php get_footer(); ?>

0 个答案:

没有答案