You need an orderby
argument.
$args = array(
'post_type' => 'custom_advert',
'posts_per_page' => 2,
'orderby' => 'rand'
);
That should pull posts in a random order and stop after retrieving the first two, hence two random posts.
You need an orderby
argument.
$args = array(
'post_type' => 'custom_advert',
'posts_per_page' => 2,
'orderby' => 'rand'
);
That should pull posts in a random order and stop after retrieving the first two, hence two random posts.