forked from hultsfredskommun/hultsfredskommun
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsingle.php
110 lines (76 loc) · 2.9 KB
/
single.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 all single posts.
*
* @package WordPress
* @subpackage Twenty_Eleven
* @since Twenty Eleven 1.0
*/
if (isset($_GET["only_content"])) {
$options = get_option("hk_theme");
echo "<style type='text/css'>" . $options["if_only_content"] . "</style>";
echo $options["if_only_content_js"];
}
if (!isset($_GET["only_content"])) :
get_header();
?>
<?php if (get_post_type() == "hk_kontakter") hk_navigation(); ?>
<div id="primary" class="primary primary--full-width">
<div id="content" role="main">
<?php endif; ?>
<?php if ( have_posts() ) : the_post(); ?>
<?php
$cat_array = array();
$from_string = "" ;
// get category from post to query related posts later..
$categories = get_the_category();
if ($categories) { foreach ($categories as $value) {
$cat_array[] = $value->term_id;
$from_string .= "<a href='" . get_category_link( $value->term_id ) . "' title='Länk till kategorien " . $value->name . "'>" . $value->name . "</a>, ";
} }
$from_string = rtrim($from_string, ", ");
// get post type
$post_type = get_post_type();
?>
<?php get_template_part( 'content', 'single' ); ?>
<?php endif; // end of the loop. ?>
<?php /* show related posts */
if (false) : // remove related
if (empty($_REQUEST["print"]) && !isset($_GET["only_content"]) && !empty($cat_array)) : ?>
<?php
// check for all taxonomies in this query
$query = array( 'category__in' => $cat_array,
'post__not_in' => array(get_the_ID()),
'posts_per_page' => 5,
);
// loop related posts
$wpq = new WP_Query($query);
if ($wpq->have_posts()) :
echo "<div class='more-from-heading'><span>Se mer från kategorierna " . $from_string . "</span></div>";
echo "<aside id='related_posts'>";
while ($wpq->have_posts()) : $wpq->the_post();
get_template_part( 'content' , get_post_type());
endwhile;
// removed dynamic load more
if (false) {
$filter = array("cat" => implode(",",$cat_array));
echo "<script type='text/javascript'>setSingleSettings = function () { \n";
echo "settings[\"maxPages\"] = " . $wpq->max_num_pages . ";\n";
echo "settings[\"numPages\"] = 0;\n";
echo "hultsfred_object[\"currentFilter\"] = \"" . addslashes(json_encode($filter)) . "\";\n";
echo "}\n</script>";
echo '<div id="dyn-posts-placeholder-2" class="dyn-posts-placeholder"></div>';
echo '<p id="dyn-posts-load-posts"><a href="#">Ladda fler sidor</a></p>';
}
echo "</aside>";
endif;
?>
<?php wp_reset_query(); ?>
<?php endif; // not only_content or print ?>
<?php endif; // false, remove related ?>
<?php if (!isset($_GET["only_content"])) : ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
<?php endif; ?>