0
isn’t a valid value for posts_per_page
. WordPress will see it as empty and default to the posts_per_page
option. If you want all the posts use nopaging
or posts_per_page => -1
.
$query = new \WP_Query([
'post_type' => 'producenter',
'nopaging' => true,
'orderby' => 'rand',
'post__not_in' => [$post->ID],
]);
As far as why it’s only showing 1 post, is that what you have set in the default posts per page option? Not sure why it would only show one post if you set posts_per_page
to 10.