Jayesh
Jayesh

Reputation: 133

How can i skip my first post using wordpress?

<?php
$pages = get_posts( array(
    'post_type' => 'post',
    'post_status' => 'publish',
    'orderby' => 'post_date',
    'orderby' => 'meta_value_num',
    'posts_per_page' => 4

) );

echo $post_id = $pages->ID ;
echo $post_thumbnail_id = get_post_thumbnail_id( $post_id );  

?>

In above, code I want to skip my first post and display rest of.

Upvotes: 0

Views: 75

Answers (1)

vrajesh
vrajesh

Reputation: 2942

Try this :

use offset parameter of get_posts() argument.

$pages = get_posts( array(
    'post_type' => 'post',
    'post_status' => 'publish',
    'orderby' => 'post_date',
    'orderby' => 'meta_value_num',
    'posts_per_page' => 4,
    'offset'=>'1'    //USE OFFSET PARAMETER
) );
//echo '<pre>';
//print_r($pages);  //Retrieve post lists
echo $post_id = $pages->ID ;
echo $post_thumbnail_id = get_post_thumbnail_id( $post_id )

Upvotes: 1

Related Questions