wordpress输出额外的html代码

【wordpress输出额外的html代码】我正在WordPress中构建主题, 我是新手, 并且正在输出图像HTML, 请帮助我解决此问题, 谢谢。

< ?php$args = array( 'numberposts' => 4, 'order'=> 'ASC', 'orderby' => 'title', 'category' => '5' ); $postslist = get_posts( $args ); foreach ($postslist as $post) :setup_postdata($post); ?> < li> < div class="timeline-image"> < a href="http://www.srcmini.com/< ?php the_permalink(); ?>"> < img class="rounded-circle img-fluid" src="http://www.srcmini.com/< ?php echo the_post_thumbnail(); ?>"> < /a> < /div> < div class="timeline-panel"> < div class="timeline-heading"> < h4 class="subheading text-left"> < ?php the_title(); ?> < /h4> < /div> < div class="timeline-body"> < p class="text-muted text-justify"> < ?php the_excerpt(); ?> & nbsp; < a href="http://www.srcmini.com/readmore.html"> Read More > > < /a> < /p> < /div> < /div> < /li> < ?php endforeach; ?>

#1你应该这样循环浏览帖子, 而不要使用foreach:
< ?php $args = array( 'post_type' => 'post', 'posts_per_page' => 4, 'orderby' => 'title', 'order' => 'ASC', 'category__in' => 5 ); $loop = new wp_query( $args ); while( $loop-> have_rows() ) : $loop-> the_row(); ?> Your article content… < h4 class="subheading text-left"> < ?php the_title(); ?> < /h4> < ?php endif; ?>

如果你需要循环浏览其他自定义帖子类型, 请使用本指南。

    推荐阅读