Granted, I may be misinterpreting you. Your post is not very clear but ...
category__and
will require the posts to be in both categories. It sounds like you need posts in any of the categories. You should be using category__in
so that you get an OR
match on the categories instead of an AND
match.
showposts
is deprecated.
Both category__and
and category__in
accept andan array. Plus, youYou are building a comma separated string of categories and then casting it as an array. That is not likely to work as expected.
Build your category array like this:
foreach($categories as $category) :
$catnumber[] = $category->ID;
endforeach;
And query like this:
$args = array(
'category__in' => $catnumber,
'posts_per_page' => 10,
'orderby' => 'rand'
);
http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters