View difference between Paste ID: V94nJDvM and PgP8CcRK
SHOW: | | - or go back to the newest paste.
1
<?php
2-
 add_action( 'save_post', 'ssc_reset_areas_transient' );
2+
/*
3-
 function ssc_get_areas_list(){
3+
 * This is how to access and build a nested areas of practice list.
4-
  if ( false === ( $areas_data = get_transient( 'areas_of_practice') ) ) {
4+
 */
5-
    ssc_set_areas_transient( );
5+
 $areas_of_practice = ssc_get_areas_list();
6-
    $areas_data = get_transient( 'areas_of_practice' );
6+
7
 foreach($areas_of_practice as $parent_area => $child_areas) {
8-
  return $attorney_data;
8+
  echo '<ul class="top-level"><li>';
9-
}
9+
  echo '<a href = "' . get_permalink($parent_area) . '">';
10-
 function ssc_set_areas_transient() {
10+
  // if thumbnail is needed for this list
11-
  $nested_posts = array();
11+
  echo get_the_thumbnail($parent_area);
12-
  $aop_args = array(
12+
  echo get_the_title($parent_area);
13-
    'post_type' => 'areas_of_practice',
13+
  echo '</a>';
14-
    'post_status' => 'publish',
14+
  if (is_array($child_areas)) {
15-
    'post_parent' => 0,
15+
    echo '<ul class="second-level">';
16-
    'order_by' => 'menu_order',
16+
    foreach ($child_areas as $child_area) {
17-
    'order' => 'ASC',
17+
      echo '<li><a href="' . get_the_permalink($child_area) . '">' . get_the_title($child_area) . '</a></li>';
18-
  );
18+
      }
19-
  $the_query = new WP_Query( $aop_args );
19+
    echo '</ul>';
20-
  if ( $the_query->have_posts() ) :
20+
21-
    while ( $the_query->have_posts() ) : $the_query->the_post(); 
21+
  echo '</li>';
22-
      $theparentid = get_the_id();
22+
23-
      
23+
    
24-
      $aop_child_args = array(
24+
25-
        'post_type' => 'areas_of_practice',
25+
 }
26-
        'post_status' => 'publish',
26+
 echo '</ul>';
27-
        'post_parent' => $theparentid,
27+
 ?>