Обработка декодирования JSON для использования в get_posts ()

Я пытаюсь пару дней пытаться использовать данные в настраиваемом поле для возврата сообщений. Вот моя функция, которую я имею в functions.php. Я могу вернуть свои сообщения, за исключением того, что они не ограничены теми, которые определены в переменной $ json. Я могу декодировать json и возвращать массив … но я не могу преобразовать его таким образом, чтобы он правильно заполнял мой массив для «posts__in» в $ dish_arg.

Может ли кто-нибудь помочь мне определить, что я делаю неправильно?

add_action ('woo_loop_before', 'hgf_home_menu'); function hgf_home_menu () { if (is_home() || is_front_page()) { wp_reset_query(); global $posts; $menu_args = array( 'post_type'=>'single_menu', 'posts_per_page' => 1, 'meta_key' => 'orderby_date', 'meta_query' => array( 'relation' => 'AND', array( 'key' => 'orderby_date', // Order-By Date field is upcoming 'value' => date("Ymd"), 'compare' => '>=' ), array( 'key' => 'orderby_date', // Order-By Date isn't more than two weeks out 'value' => date("Ymd", strtotime( "+2 weeks")), 'compare' => '<=' ) ), ); // Get menu that meets criteria $menus = new WP_Query( $menu_args ); // Show menu that meets criteria if ( $menus->have_posts() ) { while ( $menus->have_posts() ) { $menus->the_post(); } wp_reset_postdata(); // Get the menu's product/post listing $json = '[{"id":"435"},{"id":"527"},{"id":"563"},{"id":"568"}]'; $array = json_decode($json); $include = array(); foreach($array as $a) { $include[] = $a->ID; } $args = array( 'posts_per_page' => -1, 'include' => $include); $posts = get_posts($args); $dish_args = array( 'post_type' => 'product', 'post__in' => $posts, ); // Get dishes in menu listing $dishes = get_posts( $dish_args ); if ($dishes) { foreach ($dishes as $dish) { } } } else { // no posts found } /* Restore original Post Data */ wp_reset_postdata(); } }