I am trying to add the pagination to my website but each page has the same posts. I tried that code to set an automatic offset but it's not working. It keeps inserting only the first 3 posts even on page 2 and 3
function pag_in( $query ) {
$page = get_query_var( 'page' ) ? absint( get_query_var( 'page' ) ) : 1;
$offset = ($page - 1) * 3;
$query->set( 'posts_per_page', 3 );
$query->set( 'offset', $offset);
$query->set( 'order', 'ASC');
} add_action( 'pre_get_posts', 'pag_in', 1 );