首先,欢迎!
我猜你用的是这个文件front-page.php
用于显示主页
您要做的是将以下代码添加到front-page.php
:
<h2>Recent Posts</h2>
<ul>
<?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> \';
}
?>
</ul>
More information about wp_get_recent_posts()
can be found here.
您的模板文件如下所示:
<div id="main">
<div class="new_post">
...
</div>
</div>
您可以尝试将此代码放入
<div id="main">
就在结束标记之前
</div>
:
<div id="main">
<div class="new_post">
...
</div>
<h2>Recent Posts</h2>
<ul>
<?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> \';
}
?>
</ul>
</div>