我已经做了一个页面,你们可以从我的帖子中找到所有的挑逗者(用阅读更多标签制作的挑逗者)。(通过单击其中一个,您可以“打开”整篇文章,包括照片,…。这很好。在我的主页上,我想要一个简短的欢迎文本,并在侧栏中显示我最近的3篇帖子。我首先尝试使用以下代码在我的主页上获取最近的帖子
<?php
function recentPosts() {
$rPosts = new WP_Query();
$rPosts->query(\'showposts=3\');
while ($rPosts->have_posts()) : $rPosts->the_post(); ?>
<a href="<?php the_permalink();?>"><?php the_post_thumbnail(\'recent-thumbnails\'); ?></a>
<h2><a href="<?php the_permalink(); ?>"><?php the_title();?></a></h2>
<?php the_content(); ?>
<?php endwhile;
wp_reset_query();
}
?>
这是很好的工作,但在我的主页上,我从我的文章中得到了所有的内容,我只想要一个挑逗。(例如,2行)。我不知道在这里怎么做。下面是主页的代码。<?php
/**
* @content not visible
* @content not visible
*
* Template Name: homepage
*/
?>
<?php get_header(); ?>
<?php echo recentPosts(); ?>
<?php the_content(); ?>
<?php get_footer(); ?>