forked from roots/sage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate-resources.php
61 lines (55 loc) · 1.74 KB
/
template-resources.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
<?php
/*
Template Name: Resources Template
*/
function get_first_paragraph($in){
global $post;
$str = wpautop( $in );
$str = substr( $str, 0, strpos( $str, '</p>' ) + 4 );
$str = strip_tags($str, '<a><strong><em>');
return '<p>' . $str . '</p>';
}
$post_args = array(
'post_parent' => $post->ID,
'post_type' => 'page',
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'ASC',
'post_status' => 'publish' );
$children = get_posts($post_args);
?>
<div class="container">
<?php foreach ($children as $child) : ?>
<?php $subpost_args = array(
'post_parent' => $child->ID,
'post_type' => 'page',
'posts_per_page' => 6,
'orderby' => 'menu_order',
'order' => 'ASC',
'post_status' => 'publish' );
$subchildren = get_posts($subpost_args);
?>
<div class="row">
<div class="col-xs-12">
<div class="document-col">
<div class="row document-row">
<div class="col-sm-8">
<div class="document-box">
<h2><?php echo $child->post_title; /*print_r($child);*/?></h2>
<p><?php echo get_first_paragraph($child->post_content) ?></p>
<a class="button right" href="<?php echo get_permalink($child->ID); ?>">View More</a>
</div>
</div>
<div class="col-sm-4">
<div class="document-entries">
<?php foreach ($subchildren as $subchild) : ?>
<a href="<?php echo get_permalink($subchild->ID); ?>"><?php echo $subchild->post_title; ?></a>
<?php endforeach ?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php endforeach ?>
</div>