我希望在我的主页横幅上显示一些尚未确定数量的最近帖子(不超过5篇)。对于每个帖子,我想显示标题、发布日期、作者和特色图片作为内容缩略图的背景。
我想知道WordPress的功能是什么。我还想自定义HTML格式。我得到的最接近的结果是
<?php
<!-- Post carousel -->
<div class="cs-post-carousel-layout">
<div class="cs-container swiper-container">
<div class="swiper-wrapper">
<?php
// define query arguments
$args = array(
\'posts_per_page\' => 8, // your \'x\' goes here
\'nopaging\' => true
// possibly more arguments here
);
// set up new query
$tyler_query = new WP_Query( $args );
// loop through found posts
while ( $tyler_query->have_posts() ) : $tyler_query->the_post();
//Post item -->
echo \'<div class="swiper-slide">\'.
\'<div class="cs-post-item">\'.
\'<div class="cs-post-category-icon">\'.
\'<a href="\'.
get_permalink().
\'"></i></a>\'.
\'</div>\'.
\'<div class="cs-post-thumb">\'.
\'<a href="post_standard.html"><img src="demo/carousel/1.jpg" alt="UniqMag"></a>\'.
\'</div>\'.
\'<div class="cs-post-inner">\'.
\'<h3><a href="\'.
get_permalink().
\'">\'.
get_the_title().
\'</a></h3>\'.
//\'<div class="cs-post-meta cs-clearfix">\'.
// \'<span class="cs-post-meta-author"><a href="post_standard.html">J. Doe</a></span>\'.
// \'<span class="cs-post-meta-date">Sep 19, 2015</span>\'.
//\'</div>\'.
\'</div>\'.
\'</div>\'.
\'</div>\';
endwhile;
// reset post data
wp_reset_postdata();
?>
</div>
</div>
</div>