forked from greggsky/sandy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
content-library.php
87 lines (66 loc) · 2.31 KB
/
content-library.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
81
82
83
84
85
86
87
<?php
/**
* The template used for displaying the Library page content in page-custom.php
*
* @package WordPress
* @subpackage Foghorn
* @since Foghorn 0.1
*/
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<h1 class="leader"><?php the_title(); ?></h1>
<?php edit_post_link( __( 'Edit', 'foghorn' ), '<span class="edit-link">', '</span>' ); ?>
</header><!-- .entry-header -->
<div class="entry-content">
<?php the_content(); ?>
<h2>Topics</h2>
<!-- From functions.php - accepts the taxonomy name and outputs TOC-type nav -->
<?php get_custom_taxonomy_list ('library_categories'); ?>
<?php
//Specify taxomony to be used
$taxonomy = 'library_categories';
//Get array of taxonomy terms
$taxonomy_query = get_terms($taxonomy);
foreach ($taxonomy_query as $taxonomies => $taxonomy) {
//Display the taxonomy name as a heading with IDanchor
echo '<a id="' . $taxonomy->slug . '"></a><h2 class="category-title">' . $taxonomy->name . '</h2>';
echo '<ul class="library"><li class="entry-item">';
//Get array of posts for taxonomy term
$args = array(
'post_type' => 'library_items',
'taxonomy' => 'library_categories',
'term' => $taxonomy->name,
'orderby' => 'title',
'order' => 'ASC'
);
$post_query = new WP_Query($args);
if( $post_query->have_posts() ) {
while ($post_query->have_posts()) : $post_query->the_post(); ?>
<h3 class="item-title">
<?php
//If the item links to an external source, link there
if (get_post_custom_values('wpcf-resource-url')) {
echo '<a href="';
echo get_post_meta($post->ID, 'wpcf-library-link', true);
echo '">';
} else { //Or else link to the post ?>
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">
<? } ?>
<?php the_title(); ?></a></h3>
<?php
//If there is a source listing, display it
if (get_post_custom_values('wpcf-library-source')) {
echo '<cite rel="source">' . get_post_meta($post->ID, 'wpcf-library-source', true) . '</cite>';
}
?>
<?php the_content(); ?>
<?php
endwhile;
}
echo '</li></ul>';
}
wp_reset_query(); // Restore global post data stomped by the_post().
?>
</div><!-- .entry-content -->
</article><!-- #post-<?php the_ID(); ?> -->