0

wordpressランダム投稿プラグイン用のこの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 – 公開ステータスのブログ投稿のみを選択します。
  • オフセット - ???

誰かが私のためにこれを定義できますか.

4

1 に答える 1

8

オフセットはページネーションに使用されます。ドキュメントから:

オフセット(int) - 移動または通過するポストの数。注: オフセット パラメータを設定すると、ページ パラメータは無視されます。

于 2013-01-12T14:33:42.600 に答える