This repository was archived by the owner on May 2, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpage-messages.php
80 lines (67 loc) · 2.74 KB
/
page-messages.php
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
<?php
/*
Template Name: Archives with Content
*/
?>
<?php get_header(); ?>
<?php
$show_nav = false;
$post_ancestors = ( isset($post->ancestors) ) ? $post->ancestors : get_post_ancestors($post);
$top_page = $post_ancestors ? end($post_ancestors) : $post->ID; //get the top page id
$childrenOfParent = get_pages('child_of='.$top_page->ID);
$childrenOfMe = get_pages('child_of='.$post->ID);
// show nav if this page is parent and has children
if( count( $post_ancestors ) == 0 ){
$show_nav = ( count($childrenOfMe) == 0 );
}else{
// OR if child page has siblings
$show_nav = ( count($childrenOfParent) == 0 );
}
?>
<div id="main" role="main" <?php if( $show_nav ) { ?>class="no_children"<?php } ?> >
<section id="page">
<?php if (have_posts()) : while (have_posts()) : the_post();?>
<div class="widget" id="post">
<div>
<header><h1 id="post-<?php the_ID(); ?>"><?php the_title();?></h1></header>
<?php the_content(); ?>
<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
<?php endwhile; endif; ?>
<h2>Most Recent Messages</h2>
<?php
$args = array( 'numberposts' => 10, 'post_type' => 'nh_message' );
$lastposts = get_posts( $args );
foreach($lastposts as $post) : setup_postdata($post); ?>
<article class="audio">
<p class="meta"><strong>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></strong><br><a href="#">Todd Stewart</a> | <time pubdate datetime=""><abbr title="August">Aug</abbr> 7, 2011</time></p>
<div class="audio-player"><?php the_excerpt(); ?></div>
<?php
$args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID );
$attachments = get_posts($args);
if ($attachments) {
foreach ( $attachments as $attachment ) {
apply_filters( 'the_title' , $attachment->post_title );?>
<p class="slides-link"><?php echo wp_get_attachment_link( $attachment->ID, '' , false, false, 'Download Slides'); ?></p>
<?php
}
}
?>
</article>
<?php endforeach; ?>
</div>
</div>
</section>
<?php // hide secondary nav if no children
if( count( $children ) != 0 ) : ?>
<nav class="secondary">
<?php
// left sidebar holds page nav
if ( is_active_sidebar( 'primary-widget-area' ) ) : ?>
<?php dynamic_sidebar( 'primary-widget-area' ); ?>
<?php endif; ?>
</nav>
<?php endif; ?>
<?php get_sidebar(); ?>
</div>
<?php get_footer(); ?>