Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php “偏移量”=>1(WordPress)的含义是什么_Php_Wordpress - Fatal编程技术网

Php “偏移量”=>1(WordPress)的含义是什么

Php “偏移量”=>1(WordPress)的含义是什么,php,wordpress,Php,Wordpress,我为wordpress random post插件编写了以下php代码: <?php global $post; $tmp_post = $post; $args = array( 'numberposts' => 5, 'orderby' => 'rand', 'post_status' => 'publish', 'offset' => 1); $rand_posts = get_posts( $args ); foreach( $rand_posts as $

我为wordpress random post插件编写了以下php代码:

<?php
global $post;
$tmp_post = $post;
$args = array( 'numberposts' => 5, 'orderby' => 'rand', 'post_status' => 'publish', 'offset' => 1);
$rand_posts = get_posts( $args );
foreach( $rand_posts as $post ) : ?>
    <li><h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2><p><?php the_excerpt(); ?>
    </p></li>
<?php endforeach; ?>
</ul>
<?php $post = $tmp_post; // reset the $post to the original ?>
我想知道代码“offset”=>1的含义是什么。我已经向其他人了解了,例如:

Numberpost-您希望显示多少篇文章? Orderby–从我们的博客文章列表中随机选择。 Post_status–仅选择处于发布状态的博客文章。 偏移量-???
有人能帮我定义一下吗。

偏移量用于分页。从:

offset int—要置换或传递的桩号。注意:设置偏移参数将忽略分页参数


偏移量是开始的位置。例如,如果设置为10,则它将从表的第10行开始。它经常用于分页。请看:对不起,克里克,我理解有困难。所以如果我把它设为1,它将以什么开始?@krike,我没有检查,但计数可能以0开始。所以偏移量10将从第9行开始。上面的代码是显示wordpress随机博客文章,这意味着将偏移量设置为1意味着什么?1意味着它将从什么开始?