I have created a function and passing dynamically the comma separated values to wp_args. When i echo variable i get the exact as needed and passing statci gies result but while passing variable name, I do not get results.
$excludepages1 = "12,14";
$excludepages2 = "'".implode("','", explode(",", $excludepages1))."'";
$excludepages = str_replace('"', '', $excludepages2);
Now If i echo $excludepages
I get '12','14'
But when i pass here
$children = get_posts( array(
'post_type' =>'page',
'posts_per_page' =>-1,
'post_parent' => $post_id,
'orderby' => 'menu_order',
'order' => 'ASC',
'post__not_in' => array($excludepages)));
I do not get any result and if instead of variable i pass '12','14'
, I get results, Can you please help?