在一列中显示三个帖子项目


display three post items in a column

我正在使用codex中的以下代码将最后三篇文章放在主页上的一个框中,我也将使用自定义的"事件日期"来做类似的事情

新手问题我知道,但我将如何让它显示帖子内容和标题?-每当我尝试添加内容时,它显示的是页面内容,而不是帖子内容!

TIA-

<?php
$args = array( 'numberposts' => '5' );
$recent_posts = wp_get_recent_posts( $args );
foreach( $recent_posts as $recent ){
echo '<li><a href="' . get_permalink($recent["ID"]) . '" title="Look '.esc_attr($recent["post_title"]).'" >' .   $recent["post_title"].'</a> </li> ';
}
?>

这里有一个例子。显示列或框标题、文章标题、日期、摘录和缩略图。你可以去掉你想要使用的部分,当然你必须用自己的css进行样式设计。希望能有所帮助。

<div id="col-1">
    <h4>News & Events</h4>
    <?php $counter = 3;
        $recentPosts = new WP_Query();
        $recentPosts->query('showposts=3');?>
    <?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
    <div id="col1left">
        <?php the_post_thumbnail(); ?>
    </div><!-- CLOSE COL1LEFT -->
    <div id="col1right">
        <div class="NE_title">
            <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
        </div><!-- CLOSE NE_TITLE -->
        <div class="NE_date">
            <?php the_date(); ?>
        </div><!-- CLOSE NE_DATE-->
        <p><?php echo get_excerpt(75); ?></p>
    </div><!-- CLOSE COL1RIGHT -->
        <?php endwhile; ?>    
</div><!-- CLOSE COLUMN-1 -->