Story Select

[insert_php] $args = array( //’pad_counts’ => 1, //’orderby’ => ‘menu_order’, //’order’ => ‘DESC’, ‘hide_empty’ => 0, ‘parent’ => 0 ); $parent_chapters = get_terms( ‘chapters’, $args ); function getChapter($i) { } [/insert_php]
[insert_php] $parent_chapter = $parent_chapters[0]; $output = ”; $parent_args = array( ‘numberposts’ => 1, ‘post_type’ => ‘comic’, ‘orderby’ => ‘post_date’, ‘order’ => ‘ASC’, ‘post_status’ => ‘publish’, ‘chapters’ => $parent_chapter->slug, ); $qposts = get_posts( $parent_args ); if (is_array($qposts) && !is_wp_error($qposts)) { $qposts = reset($qposts); //if ($parent_chapter->count) $count = ‘ (‘.$parent_chapter->count.’) ‘; } $child_chapters = get_term_children( $parent_chapter->term_id, ‘chapters’ ); // MODIFICATION!!! Sorting stories $stories = array(); foreach($child_chapters as $child) { $term = get_term_by(‘id’,$child,’chapters’); array_push($stories, $term); } usort($stories,storySort); foreach ($stories as $child_term) { if ($child_term->count) { $child_args = array( ‘numberposts’ => 1, ‘post_type’ => ‘comic’, ‘orderby’ => ‘post_date’, ‘order’ => ‘ASC’, ‘post_status’ => ‘publish’, ‘chapters’ => $child_term->slug ); $qcposts = get_posts( $child_args ); if (is_array($qcposts)) { $qcposts = reset($qcposts); //$output .= ‘ID) .” class=’block-link’>”; $output .= “

“.$child_term->name . “

“; $output .= get_the_post_thumbnail( $qcposts->ID, ‘thumbnail’ ); $output .= “
“; } } } echo $output; [/insert_php]
[insert_php] $parent_chapter = $parent_chapters[1]; $output = ”; $parent_args = array( ‘numberposts’ => 1, ‘post_type’ => ‘comic’, ‘orderby’ => ‘post_date’, ‘order’ => ‘ASC’, ‘post_status’ => ‘publish’, ‘chapters’ => $parent_chapter->slug, ); $qposts = get_posts( $parent_args ); if (is_array($qposts) && !is_wp_error($qposts)) { $qposts = reset($qposts); //if ($parent_chapter->count) $count = ‘ (‘.$parent_chapter->count.’) ‘; } $child_chapters = get_term_children( $parent_chapter->term_id, ‘chapters’ ); // MODIFICATION!!! Sorting stories $stories = array(); foreach($child_chapters as $child) { $term = get_term_by(‘id’,$child,’chapters’); array_push($stories, $term); } usort($stories,storySort); foreach ($stories as $child_term) { if ($child_term->count) { $child_args = array( ‘numberposts’ => 1, ‘post_type’ => ‘comic’, ‘orderby’ => ‘post_date’, ‘order’ => ‘ASC’, ‘post_status’ => ‘publish’, ‘chapters’ => $child_term->slug ); $qcposts = get_posts( $child_args ); if (is_array($qcposts)) { $qcposts = reset($qcposts); //$output .= ‘ID) .” class=’block-link’>”; $output .= “

“.$child_term->name . “

“; $output .= get_the_post_thumbnail( $qcposts->ID, ‘thumbnail’ ); $output .= “
“; } } } echo $output; [/insert_php]
[insert_php] $parent_chapter = $parent_chapters[2]; $output = ”; $parent_args = array( ‘numberposts’ => 1, ‘post_type’ => ‘comic’, ‘orderby’ => ‘post_date’, ‘order’ => ‘ASC’, ‘post_status’ => ‘publish’, ‘chapters’ => $parent_chapter->slug, ); $qposts = get_posts( $parent_args ); if (is_array($qposts) && !is_wp_error($qposts)) { $qposts = reset($qposts); //if ($parent_chapter->count) $count = ‘ (‘.$parent_chapter->count.’) ‘; } $child_chapters = get_term_children( $parent_chapter->term_id, ‘chapters’ ); // MODIFICATION!!! Sorting stories $stories = array(); foreach($child_chapters as $child) { $term = get_term_by(‘id’,$child,’chapters’); array_push($stories, $term); } usort($stories,storySort); foreach ($stories as $child_term) { if ($child_term->count) { $child_args = array( ‘numberposts’ => 1, ‘post_type’ => ‘comic’, ‘orderby’ => ‘post_date’, ‘order’ => ‘ASC’, ‘post_status’ => ‘publish’, ‘chapters’ => $child_term->slug ); $qcposts = get_posts( $child_args ); if (is_array($qcposts)) { $qcposts = reset($qcposts); //$output .= ‘ID) .” class=’block-link’>”; $output .= “

“.$child_term->name . “

“; $output .= get_the_post_thumbnail( $qcposts->ID, ‘thumbnail’ ); $output .= “
“; } } } echo $output; [/insert_php]