This question already has an answer here:
I want to use this code in wordpress theme.
<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>
but there is something wrong!
Parse error: syntax error, unexpected 'large' (T_STRING), expecting ',' or ';' in
How can I fix this code?
Thanks...
</div>
You have not cloded tags properly. Try this :
<?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();
?>
as a general rule, you fix syntax errors in hard-to-read code by
a) improving the code layout until the error is obvious b) removing the offending code block and gradually putting it back
Add a ;
at the end of you string (with the generated HTML-Code).