-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
124 lines (98 loc) · 5.01 KB
/
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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
/**
* The main template file
*
* This is the most generic template file in a WordPress theme
* and one of the two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* E.g., it puts together the home page when no home.php file exists.
*
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package Stoffu
*/
/**
* Config variables
*
*/
if ( isset( $_GET['utgave'] ) ) {
$currentIssue = $_GET['utgave'];
} else {
$currentIssue = 24;
}
$previousIssue = $currentIssue - 1;
$linkPrevious = '/?utgave=' . $previousIssue;
get_header();
if ( have_posts() ) :
if ( is_home() && ! is_front_page() ) : ?>
<header>
<h1 style="" class=""><?php single_post_title(); ?></h1>
</header>
<?php
endif;
$currentIssueCat = 'Utgave ' . $currentIssue;
$sticky = get_option( 'sticky_posts' );
$args_nonsticky = array(
'showposts' => -1,
'category_name' => $currentIssueCat,
'post__not_in' => $sticky
);
$args_sticky = array(
'posts_per_page' => -1,
'category_name' => $currentIssueCat,
'post__in' => $sticky
);
$the_query_sticky = new WP_Query($args_sticky);
$the_query_nonsticky = new WP_Query($args_nonsticky);
if( !$the_query_sticky -> have_posts() && !$the_query_nonsticky -> have_posts() ) {
echo "<span style='padding: 150px;'>Finner ingen artikler. Husk at forsiden leter etter artikler i kategorien «Utgave xx» hvor xx defineres i admin dashboard -> theme options. Nå er den satt til å vise utgave </span>" . $currentIssue;
} else {
if ( $sticky ) {
while ($the_query_sticky->have_posts()) : $the_query_sticky->the_post();
require( get_template_directory() . '/template-parts/content-aside.php' );
require( get_template_directory() . '/template-parts/mostread.php' );
echo '<div class="frontpage-margin hidden-md-down" style="margin-top: 10vh !important;">
<div id="siste-saker" class="mest-lest">
Siste saker
</div>
</div>';
endwhile;
}
while ($the_query_nonsticky->have_posts()) : $the_query_nonsticky->the_post();
// these posts have drawings which is best a bit smaller than usual
if ( in_category( 'bergen-revels' ) or in_category( 'quiz' ) or in_category( 'leder' ) ) {
require( get_template_directory() . '/template-parts/force-smaller-img.php' );
// if post format is standard, get_post_format actually returns null (!). Hence we want to require content-standard.php
} elseif ( empty( get_post_format() ) ) {
require( get_template_directory() . '/template-parts/content-standard.php' );
// else we can fetch template file for the format, e.g. content-aside.php for cover (renamed in functions.php)
} else {
get_template_part('template-parts/content', get_post_format() );
}
endwhile;
}
/*
This doesnt work because it only gets the aspect ratio of first post. Maybe not 100% correct implementation of the query loop
elseif ( $aspectRatio > 2.6 ) {
require( get_template_directory() . '/template-parts/content-chat.php' );
// if post format is standard, get_post_format actually returns null (!). Hence we want to require content-standard.php
}
*/
endif;
wp_reset_query();
if ($currentIssue > 1) {
?> <div id="next-issue-nav" class="frontpage-margin neste-utgave feed-item component portrait neste-utgave" style="background-color: #f9f7f1 !important; box-shadow: none !important; ">
<a class="no-decoration frontpage-margin neste-utgave feed-item component portrait" href="<?php echo $linkPrevious ?>" style="background-color: #f9f7f1 !important; ">
<div id="line-button" class="to-next-issue feed-text-container" style="flex: 2 !important; text-align: center; padding: 15px 0;" >
<span class="nestensvart" style="white-space: nowrap; ">Gå til utgave <div style="font-family: 'Ludacrys', serif; display: inline;"> #</div><?php echo $previousIssue; ?></span>
</div>
<div class="feed-image-container" style="background-color: #f9f7f1 !important; border-right: 0 !important;">
<img style="" class="feed-image inline img-fluid issue-nav-img" src="/wp-content/uploads/forsider/utgave<?php echo $previousIssue ?>.jpg">
</div>
</a>
</div>
<?php
} ?>
<!-- <span style="white-space: nowrap;">utgave <i class="fa fa-angle-right rotate-mobile" style="font-weight: 400; padding-left: 10px;" aria-hidden="true"></i></span> -->
<?php
get_footer();