How can I skip the first post in WordPress?
<?php
$recentPosts = new WP_Query();
$recentPosts->query(array('showposts' => 6,'post_type' =>array('stiri')));
?>
<?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
add_action( 'pre_get_posts' , 'wpsites_exclude_latest_post' , 1 ); This code will exclude the latest post from displaying on your home page loop. The offset is set to one, so only the first post will be hidden.
To Exclude a Page From WordPress Search Results Excluding a page is done the same way you exclude a post. Go to your list of pages and click the “Edit” link for the post you would like to exclude. Scroll down to the bottom right of the post. Check the box for “Exclude from Search Results.”
Use the offset
parameter:
<?php
$recentPosts = new WP_Query( 'offset=1' ) );
$recentPosts->query(array('showposts' => 6,'post_type' =>array('stiri')));
?>
<?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With