Passing variable to post__in not working?
-
Hey Guys,
I’m using a meta box to store a bunch of page ID. When I try to pass the page ID’s to the post__in parameter of WP_Query it only seems to take the first ID, not all of them.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;
If you do that, you’ll only get one post. Where as if you replace ‘array($relatedpages)’ with ‘array(55, 33, 22)’ you’ll get all 3 posts.
Is it something I’m doing wrong with my PHP syntax?
Thanks,
Drew
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Passing variable to post__in not working?’ is closed to new replies.