我在函数.php中编写了下面的代码,以便为最新的博客文章创建一个简码。在wordpress中的最新博客文章
function wptuts_recentpost($atts, $content=null){
$getpost = get_posts(array('number' => 1));
$getpost = $getpost[0];
$return = $getpost->post_title . "<br />" . $getpost->post_excerpt . "…";
$return .= "<br /><a href='" . get_permalink($getpost->ID) . "'>
<em>read more →</em></a>";
return $return;
}
add_shortcode('newestpost', 'wptuts_recentpost');
我怎么可能改变,这样我可以创建短代码, 第2,第3和第4的最新博客文章?如下面的链接中提到的
只是传递参数/ https://developer.wordpress.org/plugins/ shortcodes/shortcodes-with-parameters/ –