In wordpress I added a function which sets the offset like so:
add_action('pre_get_posts', 'myprefix_query_offset', 1 );
function myprefix_query_offset(&$query) {
if ( ! $query->is_home() ) {
return;
}
$offset = 1;
$ppp = 3;
if ( $query->is_paged ) {
$page_offset = $offset + ( ($query->query_vars['paged']-1) * $ppp );
$query->set('offset', $page_offset );
}
else {
$query->set('offset',$offset);
}
}
What is this function does is add an offset of 1 so that the first post doesn't get displayed. Which works fine perfect.
But of course with '!query->is_home' it litterly cuts every first post from every single query on my website.
What I need to do is apply this function to only one query.
So my question is: how can I select a specific query, is possible even possible do I need to do it some other way?
______________________Solution that worked for me__________________________
I was able to set the 'offset' parameter on the loop on my template page 'page-blog.php' like this without breaking the pagination(in functions.php):
add_action('pre_get_posts', 'myprefix_query_offset', 1 );
function myprefix_query_offset(&$query) {
if ( !is_page_template( 'page-blog.php' ) ) {
return ;
}
$offset = 1;
$ppp = 3;
if ( $query->is_paged() ) {
$page_offset = $offset + ( ($query->query_vars['paged']-1) * $ppp );
$query->set('offset', $page_offset );
}
else {
$query->set('offset',$offset);
}
}
So now it applies the offset parameter to all loops on that page that are paged. To make it only apply to the queries that were paged I had to add the parameter 'posts_per_page'=> -1' to the query that isn't paged and doesn't need an offset. So in my case this was:
$featured_item = array(
'post_type'=> 'post',
'status' => 'publish',
'posts_per_page'=> -1
);
get_posts($featured_item);
This solution allowed to display the latest post separately and of course the all the post with a pagination and offset. Maybe somebody will have use for it.
Many Thanks to s_h_dum, I am forever grateful for your help!