2016-12-30 109 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'来避免所有这些'<?'s。 – Andy

回答

0

您还没有正确标记标记。 试试这个:

<?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

作为一般规则,你修复语法错误难以读取的代码由

一)改善代码布局,直到错误是显而易见的 b)去除有问题的代码并逐渐将其放回

0

在您的字符串末尾添加;(使用生成的HTML代码)。

相关问题