-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpage-treatments.php
139 lines (91 loc) · 5.74 KB
/
page-treatments.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
/*
* Template Name: Page Treatments
* Description: Template for Treatments with two columns with featured image
*/
?>
<?php get_header(); ?>
<div class="custom-container">
<!--get custom category from URL-->
<!-- benny-->
<?php $custom_cat = $_GET['treatment-category']; //defined in functions.php
?>
<!-- get custom category name from slug-->
<?php $cat_term = get_term_by('slug', $custom_cat, 'treatment-category');
$cat_name = $cat_term->name; ?>
<!--Section with customized large banner image-->
<?php $one = get_theme_mod('page-layout-display');?>
<!--If user wants to display Image-->
<?php if ( $one == 'Yes') { ?>
<section class="page-layout-image banner">
<div class="container">
<!-- <h1><?php echo get_theme_mod('front-page-layout-heading'); ?>
</h1>-->
<h1 class="page-title-white">
<?php echo $cat_name ?>
</h1>
</div>
</section>
<?php } ?>
<?php if ( $one == 'No') { ?>
<section class="page-layout-none">
<h1 class="page-title-white small">
<?php echo $cat_name ?>
</h1>
</section>
<?php } ?>
<!--Section for pages with two columns-->
<section class="two-columns">
<?php //tex-query for custom taxonomy
$args = array('post_type' => 'treatment-posts',
'post_per_page' => -1, //unlimited posts
'tax_query' => array(
'relation' => 'OR',
array(
'taxonomy' => 'treatment-category',
'field' => 'slug',
'terms' => array($custom_cat),
'include_children' => true,
'operator' => 'IN'
)
)
);
$loop = new WP_Query( $args );
if( $loop->have_posts()) :
$i = 1;
while( $loop->have_posts()) : $loop->the_post(); ?>
<div class="img-text-parent ">
<?php if ($i % 2 == 1) { //variabeln /2 ska INTE gå jämnt upp ?>
<div class="img-text-part text" >
<h2><?php the_title(); ?></h2>
<p><?php the_content(); ?></p>
</div> <!--/ >-->
<div class="img-text-part img" >
<?php the_post_thumbnail('normal-thumbnail'); ?>
</div> <!--/. >-->
<?php } ?>
<?php if ($i % 2 == 0) { ?>
<div class="img-text-part img" >
<?php the_post_thumbnail('large-thumbnail'); ?>
</div> <!--/. >-->
<div class="img-text-part text" >
<h2><?php the_title(); ?></h2>
<p><?php the_content(); ?></p>
</div> <!--/ >-->
<?php } ?>
</div><!-- /.img-text-parent-->
<?php $i++;
endwhile;
else : ?>
<p><?php __('No Post Found'); ?></p>
<?php endif;
//now wp is the boss again
wp_reset_postdata();
?>
<!--get link-section.php -->
<?php if ($cat_name == 'Shiatsu') { ?>
<?php get_template_part('parts/link-section'); ?>
<?php } ?>
</section>
</div><!-- /.custom-container -->
<?php get_footer(); ?>