function getJsonAgeGroups($parent_id) { $classAgeGroup = "POFTREE\\agegroup"; $childs = array(); $args = array('numberposts' => -1, 'posts_per_page' => -1, 'post_type' => 'pof_post_agegroup', 'meta_query' => array(array('key' => 'suoritusohjelma', 'compare' => '=', 'value' => $parent_id)), 'order' => 'ASC', 'orderby' => 'meta_value', 'meta_key' => 'agegroup_min_age', 'meta_type' => 'NUMERIC'); $the_query = new WP_Query($args); if ($the_query->have_posts()) { while ($the_query->have_posts()) { $the_query->the_post(); $child = new $classAgeGroup(); $child = getJsonItemBaseDetails($child, $the_query->post); $child = getJsonItemDetailsAgegroup($child, $the_query->post, 'fi'); $child->title = $the_query->post->post_title; $child->taskgroups = getJsonTaskGroups($the_query->post->ID); array_push($childs, $child); } } return $childs; }
} } $title = $mypost->post_title; $ingress = get_post_meta($mypost->ID, "ingress", true); $content = $mypost->post_content; if ($lang != "FI") { $title = get_post_meta($mypost->ID, "title_" . strtolower($lang), true); $ingress = get_post_meta($mypost->ID, "ingress_" . strtolower($lang), true); $content = get_post_meta($mypost->ID, "content_" . strtolower($lang), true); } switch ($post_type) { case "program": $jsonItem = getJsonItemDetailsProgram($jsonItem, $mypost); break; case "agegroup": $jsonItem = getJsonItemDetailsAgegroup($jsonItem, $mypost, strtolower($lang)); break; case "taskgroup": $jsonItem = getJsonItemDetailsTaskgroup($jsonItem, $mypost, strtolower($lang)); $mandatory_tasks = getMandatoryTasksForTaskGroup($mypost->ID); $jsonItem->mandatory_task_hashes = implode(",", $mandatory_tasks->hashes); $subtask_term = getJsonTaskTerm(get_post_meta($mypost->ID, "taskgroup_subtask_term", true), strtolower($lang)); if (empty($subtask_term)) { foreach ($tree_array_orig as $tree_item) { $subtask_term = getJsonTaskTerm(get_post_meta($tree_item->ID, "taskgroup_subtask_term", true), strtolower($lang)); if ($subtask_term) { $jsonItem->subtask_term = $subtask_term; break; } } } else {