繁体   English   中英

WordPress的index.php无法正常工作

[英]Wordpress index.php not working

我正在尝试编码index.php,但由于某些错误而运行了一些代码。 我试图从头开始列出博客,并插入Wordpress编解码器的帖子链接。

这是我的索引文件的Wordpress代码。

<?php get_header(); ?>

<!-- BLOG AREA -->
<section>
        <hr class="no-margin" />
        <div class="blog-container section-content">
            <div class="container">
            <?php if (have_posts()) : ?>
                <div class="row">
                <?php while(have_posts()) : the_post(); ?>
            <div class="col-md-8">

                <ul class="negative-margin">
                        <li>
                            <h1><a href="<?php the_permalink(); ?>">" class="gray"><?php the_title(); ?></a></h1>
                            <p class="details">By <a href="#">Sam Norton</a> / On July 20, 2014 / <a href="#">Life Hacks</a></p>
                                <?php if (has_post_thumbnail()) : ?>

                                <figure>

                                        <a href="<?php the_permalink(); ?>"><img class="opacity-hover box-layer img-responsive" src="<?php the_post_thumbnail(); ?>" alt="" /></a>

                                </figure>
                            <p class="excerpt">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
                            </p>    
                            <div class="btn-margin">
                                <a href="<?php the_permalink(); ?>">" class="btn btn-primary">CONTINUE READING >>> </a>
                            </div>
                            <?php endif; ?>
                        </li>
                            <?php endwhile; ?>
                </ul>


                <div class="box-layer align-center page-nav">

                        <a href="#" class="btn">Next Page >>> </a>

                </div> 


                </div>

            <?php get_sidebar(); ?>


            </div> 
        </div> 
    </section>

<?php get_footer(); ?>

然后我得到以下错误:

Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\themewp\wp-content\themes\neoblog\index.php on line 51

知道是什么原因导致此错误吗? 我试图进行调整,但没有发现运气。 谢谢你的帮助。

我认为,如果您没有关闭此功能, if

<?php if (have_posts()) : ?>

PHP不希望文件结束,因为它仍然期待相应的endif

从所有锚点删除代码,额外>"更改代码

<a href="<?php the_permalink(); ?>">" class="btn btn-primary">CONTINUE READING >>> </a>

<a href="<?php the_permalink(); ?>" class="btn btn-primary">CONTINUE READING >>> </a>

也缺少IF关闭,因此添加更多endif

<?php endif; ?>

因此完整的代码将是:

<?php get_header(); ?>
<!-- BLOG AREA -->
<section>
<hr class="no-margin" />
<div class="blog-container section-content">
<div class="container">
  <?php if (have_posts()) : ?>
  <div class="row">
    <?php while(have_posts()) : the_post(); ?>
    <div class="col-md-8">
      <ul class="negative-margin">
        <li>
          <h1><a href="<?php the_permalink(); ?>" class="gray">
            <?php the_title(); ?>
            </a></h1>
          <p class="details">By <a href="#">Sam Norton</a> / On July 20, 2014 / <a href="#">Life Hacks</a></p>
          <?php if (has_post_thumbnail()) : ?>
          <figure> <a href="<?php the_permalink(); ?>"><img class="opacity-hover box-layer img-responsive" src="<?php the_post_thumbnail(); ?>" alt="" /></a> </figure>
          <p class="excerpt">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum </p>
          <div class="btn-margin"> <a href="<?php the_permalink(); ?>" class="btn btn-primary">CONTINUE READING >>> </a> </div>
        </li>
        <?php endif; ?>
        <?php endwhile; ?>

      </ul>
      <div class="box-layer align-center page-nav"> <a href="#" class="btn">Next Page >>> </a> </div>
    </div>
    <?php endif; ?>
    <?php get_sidebar(); ?>
  </div>
</div>
</section>
<?php get_footer(); ?>

** 1。 您没有关闭

 <?php if (have_posts()) : ?>

<?php endif(): ?>

 in the end before <?php get_sidebar();?>**

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM