-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage-attorneys.php
More file actions
142 lines (116 loc) · 4.24 KB
/
page-attorneys.php
File metadata and controls
142 lines (116 loc) · 4.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
/**
* Template Name: Attorney Landing
**/
get_header();
/*$attorneys = new WP_Query(array(
'post_type' => 'attorneys',
'orderby' => 'menu_order',
'order' => 'ASC',
'posts_per_page' => -1
));*/
global $wpdb;
global $post;
// Originally sorting was done with menu_order and a plugin to rearrange in the backend
// This is a bit ugly, but uses a custom query to sort by the last_name post meta field
$attorneys = "
SELECT wposts.*
FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
WHERE wposts.ID = wpostmeta.post_id
AND wpostmeta.meta_key = 'last_name'
AND wposts.post_type = 'attorneys'
AND wposts.post_status = 'publish'
ORDER BY wpostmeta.meta_value ASC
LIMIT 80
";
$attorneys = $wpdb->get_results( $attorneys, OBJECT );
?>
<div id="primary" class="content-area page-default">
<header class="page-header">
<div class="span12 aligncenter">
<h1 class="page-title"><?php the_title(); ?></h1>
</div>
</header>
<main id="main" class="site-main span12 aligncenter" role="main">
<aside class="aside aside-left span2 push-left">
<div class="border-block top sidebar-menu-block">
<h3 class="block-label sidebar-menu-header">Filter by practice <span class="icon-arrow-down"></span></h3>
<?php
$practices = new WP_Query(array(
'post_type' => 'practices',
'orderby' => 'title',
'order' => 'ASC',
'posts_per_page' => 100
));
?>
<ul class="practice-list sidebar-menu">
<li class="practice all active">All Practices</li>
<?php while ( $practices->have_posts() ) : $practices->the_post(); ?>
<li class="practice <?php echo $post->post_name; ?>"><?php the_title();?></li>
<?php endwhile; ?>
</ul>
</div>
<div class="border-block top sidebar-menu-block">
<h3 class="block-label sidebar-menu-header">Filter by industry <span class="icon-arrow-down"></span></h3>
<?php
$practices = new WP_Query(array(
'post_type' => 'industries',
'orderby' => 'title',
'order' => 'ASC',
'posts_per_page' => 100
));
?>
<ul class="industry-list sidebar-menu">
<li class="industry all active">All Industries</li>
<?php while ( $practices->have_posts() ) : $practices->the_post(); ?>
<li class="industry <?php echo $post->post_name; ?>"><?php the_title();?></li>
<?php endwhile; ?>
</ul>
</div>
</aside>
<section class="span9 push-right attorneys">
<?php // while ( $attorneys->have_posts() ) : $attorneys->the_post(); ?>
<?php foreach ( $attorneys as $post ) : ?>
<?php
$custom = get_post_custom( $post->ID );
$name = get_post_meta( $post->ID, 'first_name', true ) . ' ';
$name .= get_post_meta( $post->ID, 'middle_initial', true ) . ' ';
$name .= get_post_meta( $post->ID, 'last_name', true);
$title = get_post_meta( $post->ID, 'title', true );
$sec_title = get_post_meta( $post->ID, 'secondary_title', true );
// $areas_practice = get_post_meta($post->ID, 'areas_practice', true);
$areas_practice = get_post_meta($post->ID, 'areas_practice', true );
$practice_areas = '';
if ( is_array( $areas_practice ) ) {
foreach ( $areas_practice as $practice ) {
$practice_post = get_post( $practice );
$practice_areas .= $practice_post->post_name . ' ';
}
}
// $areas_practice = get_post_meta($post->ID, 'areas_practice', true);
$industries = get_post_meta( $post->ID, 'industry', true );
$attorney_industries = '';
if ( is_array( $industries) ) {
foreach ( $industries as $industry ) {
$industry_post = get_post( $industry );
$attorney_industries .= $industry_post->post_name . ' ';
}
}
?>
<article class="border-block top-right-bottom square attorney sortable all <?php echo $practice_areas . ' ' . $attorney_industries; ?> active">
<a href="<?php the_permalink() ?>">
<h3><?php echo $name; ?></h3>
<p class="titles">
<?php echo $title; ?>
<?php if ( $title && $sec_title ) echo '<br>'; ?>
<?php echo $sec_title; ?>
</p>
<?php the_post_thumbnail('attorney-thumb', array( 'class' => 'alignleft png-bg' ) ); ?>
</a>
</article>
<?php // endwhile; ?>
<?php endforeach; ?>
</section>
</main>
</div>
<?php get_footer(); ?>