我实际上正在使用这个简短的代码片段来显示我的网站上的一些内容。
<?php
global $post;
$myposts = get_posts('numberposts=3');
foreach($myposts as $post) :?>
content
<? php endforeach; ?>
我想知道是否有办法将 wp 的偏移功能合并到其中。
是的,你可以
<?php
global $post;
$args = array(
'numberposts' => 3,
'offset' => 0,
);
$myposts = get_posts($args);
foreach($myposts as $post) : setup_postdata( $post ); ?>
content
<?php endforeach; ?>
只需查看文档即可。