Found it.
In the same page I have to show two different custom post types. One post type is dislpayed on the main area, 16 per page. And the other is used to fill a list in the sidebar.
Using this piece of code I change the main query
function homepage_custom( $query )
{
if ($query->is_home() && $query->is_main_query())
{
$query->set('post_type', array( 'custom' ));
}
}
add_action( 'pre_get_posts', 'homepage_custom' );
but when I use the following in the home.php
get_side_bar();
The main query is somehow ignored, that’s why I get nothing with the check for the main query. Without the main query check, I’m always searching for my custom post type and it works for the first 16 posts and then the query from the side bar somehow breaks it in a way it loses the reference on what posts to show and I end up with the same no matter the page.
Using wp_reset_query() method, removing this query from the sidebar.php or using WP_query instances where loops iterates through local variables solves the problem.