2016-12-30 9 views
-3

私はこのコードをWordPressテーマで使用します。WordPressテーマのこのコードを修正するにはどうすればいいですか?

<ul> 
    <?php 
    $args = array('numberposts' => '5'); 
    $recent_posts = wp_get_recent_posts($args); 
    foreach($recent_posts as $recent){ 
     echo '<li> 
       <span class="l-e-right"><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" rel="bookmark"><?php echo the_post_thumbnail('large-thumb'); ?></a></span> 
        <h4><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h4> 
         <time datetime="<?php the_date('j F Y'); ?>"><?php the_date('j F Y'); ?></time> 
       <div class="clearfix"></div> 
      </li>' 
      } 
    wp_reset_query(); 
    ?> 
</ul> 

しかし、何か問題があります。

Parse error: syntax error, unexpected 'large' (T_STRING), expecting ',' or ';' in

このコードを修正するにはどうすればよいですか?

ありがとうございました...

+2

エスケープされていないシングルクォート – mathiasfk

+0

これらの '<?'をすべて避けるには、 'echo 'Link'を使うことができます。 – Andy

答えて

0

タグを正しくコピーしていません。 これを試してみてください:エラーが B明白になるまで、原則として

<?php 
    $args = array('numberposts' => '5'); 
    $recent_posts = wp_get_recent_posts($args); 
    foreach($recent_posts as $recent){ ?> 
     <li> 
       <span class="l-e-right"><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" rel="bookmark"><?php echo the_post_thumbnail('large-thumb'); ?></a></span> 
        <h4><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h4> 
         <time datetime="<?php the_date('j F Y'); ?>"><?php the_date('j F Y'); ?></time> 
       <div class="clearfix"></div> 
      </li> 
    <?php 
      } 
    wp_reset_query(); 
    ?> 
0

を、あなたは

で読みにくいコードの構文エラーを修正a)に問題のあるコードを削除する)コードレイアウトの改善ブロックして徐々にそれを戻す

0

あなたの最後に;を追加します(生成されたHTMLコードで)。

関連する問題