-
Notifications
You must be signed in to change notification settings - Fork 0
/
category-crag.php
110 lines (93 loc) · 3.3 KB
/
category-crag.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
/**
* The template for displaying Category pages
*
* @link http://codex.wordpress.org/Template_Hierarchy
*
* @package WordPress
* @subpackage Twenty_Thirteen
* @since Twenty Thirteen 1.0
*/
get_header(); ?>
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<div class="banner-map">
<iframe width="640" height="400" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps/ms?msid=205265335858135699416.00048240a25d103bca6b8&msa=0&ie=UTF8&t=m&ll=65.007224,-19.248047&spn=3.715753,15.358887&z=6&output=embed"></iframe>
</div>
<?php // Get all problems for problem count ?>
<?php // Notice: This will be heavy when the problems increase. Will maybe have to fix later ?>
<?php $args = array(
'posts_per_page' => -1,
'caller_get_posts'=> 1,
'category_name' => 'problem',
);
$my_query2 = null;
$my_query2 = new WP_Query($args); ?>
<?php if( $my_query2->have_posts() ) : ?>
<?php while ($my_query2->have_posts()) : $my_query2->the_post(); ?>
<?php $the_crag = get_field('crag'); ?>
<?php $problem_count[] = $the_crag->post_title; ?>
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_query(); ?>
<?php // Render the crag table ?>
<?php if ( have_posts() ) : ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php //link = admin_url( 'admin-ajax.php?action=my_user_vote&post_id=874' ); ?>
<?php //echo '<a class="user_vote" data-post_id="874" href="' . $link . '">vote for this article</a>'; ?>
<?php $args = array(
'posts_per_page' => -1,
'category_name' => 'crag',
'orderby' => 'title',
'order' => 'ASC'
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) : ?>
<table id="myTable" class="tablesorter">
<thead>
<tr>
<th>Crag</th>
<th>Problems</th>
<th>Boulder</th>
<th>Sport</th>
<th>Trad</th>
<th>Comments</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<tr>
<td><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></td>
<?php $type = get_field('type_of_climbing'); ?>
<td>
<?php
$count = 0;
foreach($problem_count as $problem) {
if( $problem == get_the_title() ) {
$count++;
}
}
echo $count;
?>
</td>
<td class="check"> <?php if ( in_array('Boulder', $type) ) echo 'C'; ?> </td>
<td class="check"> <?php if ( in_array('Sport climbing', $type) ) echo 'C'; ?> </td>
<td class="check"> <?php if ( in_array('Traditional climbing', $type) ) echo 'C'; ?> </td>
<td><?php comments_number('0','1','%'); ?></td>
<td><?php echo get_the_date(); ?></td>
<?php endwhile; ?>
</tbody>
</table>
<?php endif; ?>
<?php wp_reset_query(); ?>
</article>
<?php //twentythirteen_paging_nav(); ?>
<?php else : ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>