-
Notifications
You must be signed in to change notification settings - Fork 0
/
archive-courses.php
executable file
·155 lines (113 loc) · 5.36 KB
/
archive-courses.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?php get_header(); ?>
<?php
$post_id = get_the_ID();
$current_course_category = get_the_terms( $post_id, 'courses_categories' );
$course_category_id = !empty($_GET['term_id']) ? $_GET['term_id'] : '';
?>
<section class="banner courses">
<div class="info">
<h2 class="head-title"> <?php echo $current_course_category[0]->name; ?> </h2>
</div>
</section>
<section class="tab-content">
<div class="container">
<div class="row">
<div class="col-12 text-center btn-section">
<span class="cover">
<?php
$courses_categories = get_terms( array(
'taxonomy' => 'courses_categories',
'hide_empty' => false
) );
$current_course_category = get_the_terms( $post_id, 'courses_categories' );
if( count( $courses_categories ) > 0 && !empty($courses_categories) ):
foreach ( $courses_categories as $courses_category ):
if( (int) $course_category_id === (int) $courses_category->term_id ):
$active = 'active';
else:
$active = '';
endif;
?>
<a href="<?php echo home_url();?>/courses?term_id=<?php echo $courses_category->term_id;?>" class="courses_category tab-button <?php echo $active; ?>" data-course-category-id="<?php echo $courses_category->term_id; ?>"> <?php echo $courses_category->name;?> </a>
<?php
endforeach;
endif;
?>
</span>
</div>
</div>
</div>
</section>
<div class="courses_categories_section">
<?php
if ( $course_category_id ) :
?>
<section class="tab-content">
<div class="container">
<?php
// get all courses in this custom taxonomy
$courses = get_posts(
array(
'posts_per_page' => -1,
'post_type' => 'courses',
'tax_query' => array(
array(
'taxonomy' => 'courses_categories',
'field' => 'term_id',
'terms' => $course_category_id,
)
)
)
);
if( !empty($courses) && count($courses) > 0 ):
foreach ($courses as $course):
$course_id = $course->ID;
$course_title = $course->post_title;
$course_duration = get_post_meta($course_id, 'course_duration', true);
$course_equipment = get_post_meta($course_id, 'course_equipment', true);
$course_overview = get_post_meta($course_id, 'course_overview', true);
$course_thumbnail = get_the_post_thumbnail_url($course_id, 'full');
$course_permalink = get_the_permalink($course_id);
?>
<div class="row">
<div class="col-md-6 pt-5">
<h1 class="title-primary"><?php echo $course_title;?></h1>
<span class="split-line"></span>
<div class="row">
<div class="col-6 m-auto pt-1">
<img src="<?php echo get_stylesheet_directory_uri(); ?>/assets/images/time.svg" class="w-30 mr-2" alt="time">
<p class="sub-description mb-0">
Duration :
<?php echo $course_duration;?></p>
</div>
<div class="col-md-6 pt-1">
<img src="<?php echo get_stylesheet_directory_uri(); ?>/assets/images/diving-orange.svg" class="w-30 mr-2" alt="diving">
<p class="sub-description mb-0">
Equipment :
<?php echo $course_equipment;?> </p>
</div>
</div>
<p class="description-primary pt-1">
<?php echo $course_overview; ?>
</p>
<a href="<?php echo $course_permalink; ?>" class="default-btn mt-4">
Read More</a>
</div>
<div class="col-md-6 pt-5">
<a href="<?php echo $course_permalink; ?>">
<img src="<?php echo $course_thumbnail; ?>" class="bor-radius-10 img-fluid" alt="diving">
</a>
</div>
</div>
<?php endforeach; ?>
<?php else: ?>
<div class="alert alert-primary text-center" role="alert">
No Courses Found.
</div>
<a href="<?php echo home_url();?>" class="btn btn-primary back-to-home">Back to Home</a>
<?php endif; ?>
</div>
</section>
<?php endif; ?>
</div>
<?php get_footer(); ?>