2016-03-22 58 views
0

我實際上使用這個簡短的代碼片段來顯示我的網站上的一些內容。如何顯示WP中的偏移量?

<?php 
    global $post; 
    $myposts = get_posts('numberposts=3'); 
    foreach($myposts as $post) :?> 
        content 
<? php endforeach; ?> 

而且我想知道是否有辦法將wp的偏移函數合併到它中。

回答

0

是的,你可以

<?php 
    global $post; 
    $args = array(
     'numberposts' => 3, 
     'offset'  => 0, 
    ); 
    $myposts = get_posts($args); 

    foreach($myposts as $post) : setup_postdata($post); ?> 
        content 
<?php endforeach; ?> 

只要看看documentation