Kareen Lagasca
Kareen Lagasca

Reputation: 939

What is the meaning of 'OFFSET' => 1 (WordPress)

I have this php code for wordpress random post plugin:

<?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 ?>

I wanna know what is the the meaning of the code 'offset' => 1.i already understand to others such as:

can someone define this for me.

Upvotes: 0

Views: 24086

Answers (1)

MrCode
MrCode

Reputation: 64536

The offset is used for pagination. From the docs:

offset (int) - number of post to displace or pass over. Note: Setting offset parameter will ignore the paged parameter.

Upvotes: 8

Related Questions