2017-03-28 2 views
0

私はPHP7/XAMPPサーバー上でWordPressを実行しています。私は単純な "テーマ"を作ろうとしています。テーマのコードはここにあります。WordPressのループは決して終わらないのですか?

コードリスト1:header.phpの

<!DOCTYPE html> 
<html lang="en"> 
    <head> 

     <meta charset="utf-8"> 
     <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
     <meta name="viewport" content="width=device-width, initial-scale=1"> 
     <meta name="description" content=""> 
     <meta name="author" content=""> 

     <title>Blog Post</title> 

    </head> 
    <body> 

コードリスト2:

footer.php:

<?php 
    get_header(); 
?> 

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

     <div class="row"> 

      <!-- Blog Post Content Column --> 
      <div class="col-lg-8"> 
       <!-- Blog Posts --> 
       <?php 
        if(have_posts()){ 
         while(have_posts){ 
          the_post(); 
          if(the_post_thumbnail()){ 
           the_post_thumbnail('full'); 
          } 
          the_content(); 
         } 
        } 
       ?> 

      </div> 

     </div> 

    </div> 

<?php 
    get_footer(); 
?> 

コードリスト3のindex.php

 <!-- Footer --> <footer> <div class="row"> <div class="col-lg-12"> <p>Copyright &copy; Your Website 2017</p> </div> </div> <!-- /.row --> </footer> </body> </html> 

コードリスト4:のfunctions.php

<?php 

    add_theme_support("post-thumbnails"); 

私はこのPHPのエラーを取得するページの読み込みたび:

`Fatal error: Maximum execution time of 30 seconds exceeded in E:\W`WW\wordpress473\wp-includes\formatting.php on line 4786 

エラーは異なる可能性が発生したが、エラーが常に発生するラインを同じスクリプトで ページをロードするとき、PHPはスクリプトがスクリプトを停止するまで、ループは同じポストを繰り返しロードし続けます。

答えて

2

ないワードプレスが、ここではオーバーこのラインについて確認してください:

if(have_posts()){ 
    while(have_posts){ 
     the_post(); 
     if(the_post_thumbnail()){ 
      the_post_thumbnail('full'); 
     } 
     the_content(); 
    } 
} 

あなたは「have_posts()」の結果を確認していて、「have_posts」を使用したループインチそれがIterableを返す関数なら、そのtypoを修正し、whileループの "have_posts()"をループする必要があります。

これは、私がドキュメントで見つけたもので、私はrigthだったように見えます:

if (have_posts()) : 
while (have_posts()) : the_post(); 
    // Your loop code 
endwhile; 
else : 
_e('Sorry, no posts were found.', 'textdomain'); 

ENDIF。

関連する問題