【发布时间】:2016-12-30 21:36:27
【问题描述】:
我想在 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>
但是有问题!
解析错误:语法错误,意外“大”(T_STRING),预期 ',' 或者 ';'在
如何修复此代码?
谢谢...
【问题讨论】:
-
未转义的单引号
-
您可以使用
echo '<a href="' . the_permalink() . '">Link</a>来避免所有这些<?。