请帮我弄清楚我想展示的thumbnails along with recent post from a wordpress blog on static website\'s homepage.
以下代码工作正常,但我需要将帖子中的一幅图像显示为缩略图:
<?php
define(\'WP_USE_THEMES\', false);
require(\'blog/wp-blog-header.php\');
?>
<?php
$args = array( \'numberposts\' => 3, \'post_status\'=>"publish",\'post_type\'=>"post",\'orderby\'=>"post_date");
$postslist = get_posts( $args );
foreach ($postslist as $post) : setup_postdata($post);?>
// Here I want to show post\'s thumbnail
<h4 class="post-modern-title">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</h4>
<p class="post-short-info">
// Here I want to show post\'s short info
</p>
<?php endforeach; ?>
Right now it is showing like this :-
But I want to show like this :-
一
零三e>
I\'m getting following output where I\'m unable to see date in a single post:-
最合适的回答,由SO网友:Pratik Patel 整理而成
以下更新答案
<?php
define(\'WP_USE_THEMES\', false);
require(\'blog/wp-blog-header.php\');
?>
<div class="row row-60 row-sm">
<?php
$args = array( \'numberposts\' => 3, \'post_status\'=>"publish",\'post_type\'=>"post",\'orderby\'=>"post_date");
$postslist = get_posts( $args );
foreach ($postslist as $post) : setup_postdata($post);?>
<div class="col-sm-6 col-lg-4 wow fadeInLeft">
<!-- Post Modern-->
<article class="post post-modern"><a class="post-modern-figure" href="<?php the_permalink( $post->ID ); ?>" target="_top">
<?php echo get_the_post_thumbnail( $post->ID ); ?>
<div class="post-modern-time">
<!-- <time datetime=""><span class="post-modern-time-month">07</span><span class="post-modern-time-number">04</span></time> -->
<time datetime=""><span class="post-modern-time-number"><?php echo get_the_date( \'d/m\', $post->ID ); ?></span></time>
</div></a>
<h4 class="post-modern-title"><a href="<?php the_permalink( $post->ID ); ?>" target="_top"><?php the_title(); ?></a></h4>
<p class="post-modern-text"><?php the_excerpt(); ?></p>
</article>
</div>
<?php endforeach; ?>
</div>
如果有任何疑问,请尝试让我知道。