# Passing meta_box string to post__in?

Hey Guys, I'm using a meta box to store a bunch of page ID's. When I try to pass the page ID's to the post__in parameter of WP_Query it doesn't work becuase the metabox comes throug as a string, when it needs to be a comma separated integers.

So, say the "relatedpages" meta box contains: 55, 33, 22

$relatedpages = get_post_meta($post->ID, 'relatedpages', true);

$args = array( 'post_type' => 'page', 'posts_per_page' => -1, 'order' => 'ASC', 'orderby' => 'menu_order', 'post__in' => array($relatedpages)
);

$myposts = get_posts($args);
echo $myposts;  The problem is that$related pages is now "55, 33, 22" rather than 55, 33, 22

How can I overcome this? Is there a way to store just the integers in the meta box, rather than converting them to a string?

Thanks, Drew

-
By the way, to store ids, you're using a custom field. To input those ids you're using a custom metabox. –  scribu Apr 10 '11 at 2:05
Hey scribu, am I just using the wrong words in my question, or should I be storing my ID's differently? –  Drew Baker Apr 18 '11 at 17:25
Well, since you asked: scribu.net/wordpress/posts-to-posts –  scribu Apr 18 '11 at 18:03

'post__in'      => explode( ',', $relatedpages )  - Cast to int whilst we're there? array_map( 'absint', explode( ',',$relatedpages ) ) ... –  t31os Apr 10 '11 at 9:37
That's done anyway in WP_Query. –  scribu Apr 10 '11 at 14:25

Thanks for the help, but in the end I think the problem was the 'post__in' parameter can't be used in get_posts like I wanted. As per the codex for get_posts, 'include' is the way to do it.

$relatedpages = get_post_meta($post->ID, 'relatedpages', true);

$args = array( 'post_type' => 'page', 'posts_per_page' => -1, 'order' => 'ASC', 'orderby' => 'menu_order', 'include' =>$relatedpages
);

$myposts = get_posts($args);


Thanks anyway!

-