我现在正沉浸在wordpress循环中,我试图给相应的内容加标签,所以标题加H标签,摘录加p标签,等等…
到目前为止,我得到的代码是
<div id="<?php echo $page_id; ?>" class="container"><!-- begin container -->
<div id="postovi" style="display:none;">
<?php $custom_loop = new
WP_Query('showposts=5&category_name=Zanimljivosti&orderby=rand');
if ( $custom_loop->have_posts() ) : echo '<ul>'; while ( $custom_loop->have_posts() ) : $custom_loop->the_post(); echo '<li><a href="' . get_permalink() . '">' . get_the_title() . get_the_post_thumbnail($loop->post->ID, 'shop_catalog') . get_the_excerpt();'</a></li>'; endwhile; wp_reset_query(); echo '</ul>';endif;?> </div>
任何建议:)
所以您的解决方案是:
<?php
$custom_loop = new WP_Query('showposts=5&category_name=Zanimljivosti&orderby=rand');
if ( $custom_loop->have_posts() ) :
echo '<ul>';
while ( $custom_loop->have_posts() ) :
$custom_loop->the_post(); echo '<li><h2><a href="' . get_permalink() . '">' . get_the_title();
echo '</h2>' . get_the_post_thumbnail($loop->post->ID, 'shop_catalog');
echo'<p>' . get_the_excerpt();'</p></a></li>';
endwhile; wp_reset_query();
echo '</ul>';endif;
?>