Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ssc_set_areas_transient() {
- $nested_posts = array();
- $aop_args = array(
- 'post_type' => 'areas_of_practice',
- 'post_status' => 'publish',
- 'post_parent' => 0,
- 'order_by' => 'menu_order',
- 'order' => 'ASC',
- );
- $the_query = new WP_Query( $aop_args );
- if ( $the_query->have_posts() ) :
- while ( $the_query->have_posts() ) : $the_query->the_post();
- $theparentid = get_the_id();
- $aop_child_args = array(
- 'post_type' => 'areas_of_practice',
- 'post_status' => 'publish',
- 'post_parent' => $theparentid,
- 'order_by' => 'menu_order',
- 'order' => 'ASC',
- );
- $child_posts = array();
- $the_child_query = new WP_Query( $aop_child_args );
- if ( $the_child_query->have_posts() ) :
- while ( $the_child_query->have_posts() ) : $the_child_query->the_post();
- $thechildid = get_the_id();
- $child_posts = $thechildid;
- endwhile;
- print '<pre>';
- print_r ( $child_posts );
- print '</pre>';
- endif;
- $nested_posts[$theparentid][] = $child_posts;
- endwhile;
- print '<pre>';
- print_r ( $nested_posts );
- print '</pre>';
- set_transient( 'areas_of_practice', $nested_posts, 52 & WEEK_IN_SECONDS );
- endif;
- wp_reset_query();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement