From c18053f18c1953bd2c21c60be670425b452c30f5 Mon Sep 17 00:00:00 2001 From: Joshua Roy Date: Thu, 19 Nov 2015 15:37:09 -0500 Subject: [PATCH] Change sorting to last name, first name --- user-people.php | 377 ++++++++++++++++++++++++------------------------ 1 file changed, 189 insertions(+), 188 deletions(-) diff --git a/user-people.php b/user-people.php index ee9f3d3..d37532e 100644 --- a/user-people.php +++ b/user-people.php @@ -1,188 +1,189 @@ - -
- - - -
-
-
-
-
> -
- ', '' ); ?> -
-
- -
- ', '' ); ?> -
-
- -1, - 'post_type' => 'person', - 'orderby' => 'menu_order title', - 'order' => 'ASC', - ); - - - - // Settings - - $layout = get_field( "layout" ); - $people_to_display = get_field( "people_to_display" ); - $break_into_groups = get_field( "break_into_groups" ); - $specific_people = get_field( "specific_people" ); - $specific_groups = get_field( "specific_groups" ); - $specific_tags = get_field( "specific_tags" ); - $information_to_display = get_field( "information_to_display" ); - - function createTextCell($setting, $field){ - global $information_to_display; - if (in_array($setting, $information_to_display)) { - echo ''; - the_field($field); - echo ''; - } - }; - - - - if ($specific_people){ - global $specific_people; - global $args; - $post__in = array(); - foreach($specific_people as &$value){ - array_push($post__in, $value->ID); - } - $args[post__in]= $post__in; - } - - // do we need a tax query? - if ($specific_groups != false || $specific_tags != false){ - - $tax_query = array(); - - if ($specific_groups != false) { - $group_query = array( - 'taxonomy' => 'group', - 'field' => 'term_id', - 'terms' => $specific_groups - ); - array_push($tax_query, $group_query); - } - if ($specific_tags != false) { - $tag_query = array( - 'taxonomy' => 'persontag', - 'field' => 'term_id', - 'terms' => $specific_tags - ); - array_push($tax_query, $tag_query); - } - $args[tax_query] = $tax_query; - - } - if ($break_into_groups == 1 ){ - //echo '

Break into Groups

'; - - // get all the people - $the_query = new WP_Query( $args ); - - // focusing on just the people, not the rest of the query. - $people = $the_query->posts; - - // look at each person, and see each group used, use that to create a list of terms. - $groups_in_use = array(); - - foreach($people as $value){ - $id = $value->ID; - $terms = get_the_terms($id, 'group'); - if (is_array($terms)){ - foreach($terms as $key => $value){ - //duplicates will overwrite themselves... - $slug = $value->slug; - $groups_in_use[$slug]= $slug; - } - }; - } - - // sort the groups in use alphabetically - sort($groups_in_use); - - // for each item in the list of terms, do a new query, but this time we're going to limit it to ONLY items from that one group. - foreach($groups_in_use as $value){ - - // this sets up the query we'll need, and will overwrite any group queries from the original settings. - $tax_query = array(); - $group_query = array( - 'taxonomy' => 'group', - 'field' => 'slug', - 'terms' => $value - ); - array_push($tax_query, $group_query); - $args['tax_query'] = $tax_query; - - // with $arg updated, let's do a new query. - echo '

'.get_term_by('slug', $value, 'group')->name.'

'; - - if ($layout == 'grid') { - include('inc/people-grid.php'); - } - if ($layout == 'table') { - include('inc/people-table.php'); - } - - } - - } else { - - if ($layout == 'grid') { - include('inc/people-grid.php'); - } - if ($layout == 'table') { - include('inc/people-table.php'); - } - - } - ?> - - -
-
-
-
-
-
- -
- - -
- - + +
+ + + +
+
+
+
+
> +
+ ', '' ); ?> +
+
+ +
+ ', '' ); ?> +
+
+ -1, + 'post_type' => 'person', + 'meta_key' => 'last_name', + 'orderby' => 'menu_order meta_value title', + 'order' => 'ASC', + ); + + + + // Settings + + $layout = get_field( "layout" ); + $people_to_display = get_field( "people_to_display" ); + $break_into_groups = get_field( "break_into_groups" ); + $specific_people = get_field( "specific_people" ); + $specific_groups = get_field( "specific_groups" ); + $specific_tags = get_field( "specific_tags" ); + $information_to_display = get_field( "information_to_display" ); + + function createTextCell($setting, $field){ + global $information_to_display; + if (in_array($setting, $information_to_display)) { + echo ''; + the_field($field); + echo ''; + } + }; + + + + if ($specific_people){ + global $specific_people; + global $args; + $post__in = array(); + foreach($specific_people as &$value){ + array_push($post__in, $value->ID); + } + $args[post__in]= $post__in; + } + + // do we need a tax query? + if ($specific_groups != false || $specific_tags != false){ + + $tax_query = array(); + + if ($specific_groups != false) { + $group_query = array( + 'taxonomy' => 'group', + 'field' => 'term_id', + 'terms' => $specific_groups + ); + array_push($tax_query, $group_query); + } + if ($specific_tags != false) { + $tag_query = array( + 'taxonomy' => 'persontag', + 'field' => 'term_id', + 'terms' => $specific_tags + ); + array_push($tax_query, $tag_query); + } + $args[tax_query] = $tax_query; + + } + if ($break_into_groups == 1 ){ + //echo '

Break into Groups

'; + + // get all the people + $the_query = new WP_Query( $args ); + + // focusing on just the people, not the rest of the query. + $people = $the_query->posts; + + // look at each person, and see each group used, use that to create a list of terms. + $groups_in_use = array(); + + foreach($people as $value){ + $id = $value->ID; + $terms = get_the_terms($id, 'group'); + if (is_array($terms)){ + foreach($terms as $key => $value){ + //duplicates will overwrite themselves... + $slug = $value->slug; + $groups_in_use[$slug]= $slug; + } + }; + } + + // sort the groups in use alphabetically + sort($groups_in_use); + + // for each item in the list of terms, do a new query, but this time we're going to limit it to ONLY items from that one group. + foreach($groups_in_use as $value){ + + // this sets up the query we'll need, and will overwrite any group queries from the original settings. + $tax_query = array(); + $group_query = array( + 'taxonomy' => 'group', + 'field' => 'slug', + 'terms' => $value + ); + array_push($tax_query, $group_query); + $args['tax_query'] = $tax_query; + + // with $arg updated, let's do a new query. + echo '

'.get_term_by('slug', $value, 'group')->name.'

'; + + if ($layout == 'grid') { + include('inc/people-grid.php'); + } + if ($layout == 'table') { + include('inc/people-table.php'); + } + + } + + } else { + + if ($layout == 'grid') { + include('inc/people-grid.php'); + } + if ($layout == 'table') { + include('inc/people-table.php'); + } + + } + ?> + + +
+
+
+
+
+
+ +
+ + +
+ +