/
topic-index.php
85 lines (72 loc) · 2.24 KB
/
topic-index.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
<?php
/*
Template Name: Topic index
*/
?>
<?php
function sw_topic_filtering() {
$js = get_bloginfo('stylesheet_directory') . "/js/topic-filtering.js";
wp_enqueue_script('topicfilter', $js);
}
add_action('wp_enqueue_scripts', 'sw_topic_filtering');
?>
<?php get_header(); ?>
<article class="grid_8">
<div id="content">
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if ( is_front_page() ) { ?>
<h2 class="entry-title"><?php the_title(); ?></h2>
<?php } else { ?>
<h2 class="entry-title"><?php the_title(); ?></h2>
<?php } ?>
<div class="entry-content">
<?php the_content(); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-link">Pages:', 'after' => '</div>' ) ); ?>
</div><!-- .entry-content -->
</div><!-- #post-## -->
<?php endwhile; ?>
</div><!-- #content -->
<form method="get" autocomplete="off">
<div>
<input type="text" value="" name="q" id="term" placeholder="Search all topics" />
</div>
</form>
<?php
$query_string = '
SELECT *,name FROM '.$wpdb->prefix.'term_taxonomy
JOIN '.$wpdb->prefix.'terms
ON '.$wpdb->prefix.'term_taxonomy.term_id = '.$wpdb->prefix.'terms.term_id
WHERE '.$wpdb->prefix.'term_taxonomy.taxonomy = "post_tag"
ORDER by '.$wpdb->prefix.'terms.slug ASC
';
$post_tags = $wpdb->get_results($query_string);
?>
<div class="">
<table id="tags" class="abc_tags">
<thead>
<tr>
<th>Topic</th>
<th class="count">Posts</th>
</tr>
</thead>
<tbody>
<?php
foreach($post_tags as $key => $tag) {
?>
<tr>
<td><a href="<?php echo get_tag_link($tag->term_id); ?>" title="<?php echo sprintf( __( "View all posts in %s" ), $tag->name ); ?>"><?php echo $tag->name.' </a>';?></td>
<td class="count"><?php echo $tag->count;?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<!--/.letter-->
</article>
<!--/.grid_8-->
<aside id="sidebar" class="grid_4">
<?php get_sidebar(); ?>
</aside>
<!-- /.grid_4 -->
<?php get_footer(); ?>