-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathposts-practice.php
More file actions
executable file
·96 lines (77 loc) · 2.48 KB
/
posts-practice.php
File metadata and controls
executable file
·96 lines (77 loc) · 2.48 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
<?php
/**
* Generate posts for a specific practice (duplicate of attorney template, could probably be reworked)
*/
$query_vars = $wp->query_vars;
$practice = $query_vars['practice'];
$practice_id = carr_get_post_id_by_slug( $practice, 'practices' );
// If related practice is found, fire a 404 (there may be a way to get all this into functions.php
if ( ! $practice_id ) {
global $wp_query;
$wp_query->set_404();
status_header(404);
nocache_headers();
include( get_query_template( '404' ) );
die();
}
$practice_post = get_post( $practice_id );
// This isn't working at the moment, need a way to set the title for the post's <head>
global $post;
$post = $practice_post;
setup_postdata( $post );
get_header();
?>
<div id="primary" class="content-area page-default">
<header class="page-header">
<div class="span12 aligncenter">
<h1 class="page-title"><?php echo $practice_post->post_title; ?></h1>
</div>
</header>
<main id="main" class="site-main span12 aligncenter" role="main">
<aside class="aside aside-left span2 push-left">
<?php carr_news_events_sidebar(); ?>
</aside>
<section class="span9 push-right">
<?php ?>
<?php
// This wonderful mess essentially grabs all posts, and loops through them to find
// ones with this practice in a post meta field containing a serialized array of
// practice ids (hence the inability to query directly).
$loop = new WP_Query( array(
'post_type' => 'post',
'orderby' => 'date',
'order' => 'DESC',
'posts_per_page' => 300
) );
$i = 0;
$color_class = 'odd';
while ( $loop->have_posts() ) :
$loop->the_post();
$post_practices = get_post_meta( $post->ID, 'post_practices', 'single' );
if ( is_array( $post_practices ) && in_array( $practice_id, $post_practices ) ) :
?>
<article class="border-block top-right-bottom square blog-post <?php echo $color_class; ?>">
<h4 class="timestamp"><span class="month"><?php the_time('M. '); ?></span><span class="day-year"><?php the_time('d, Y'); ?></span></h4>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
</article>
<?php
if ( 'even' == $color_class ) {
$color_class = 'odd';
} else {
$color_class = 'even';
}
?>
<?php
$i ++;
endif;
endwhile;
if ( $i == 0 ) :
?>
<article>
<p>No posts found</p>
</article>
<?php endif; ?>
</section>
</main><!-- #main -->
</div><!-- #primary -->
<?php get_footer(); ?>