-
Notifications
You must be signed in to change notification settings - Fork 0
/
page-location.php
104 lines (86 loc) · 2.45 KB
/
page-location.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
<?php
/**
* The template for displaying all pages
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages
* and that other 'pages' on your WordPress site may use a
* different template.
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package Tweeling_Bakery
*/
get_header();
?>
<main id="primary" class="site-main">
<?php
while ( have_posts() ) :
the_post();
get_template_part( 'template-parts/content', 'page' );
// call map template part
get_template_part( 'template-parts/content', 'location' );
// location CPT
$args = array(
'post_type' => 'tweel-location',
'posts_per_page' => -1
);
$query = new WP_Query( $args );
if ( $query -> have_posts() ){
echo '<div class="location-details-wrapper">';
while ( $query -> have_posts() ) {
$query -> the_post();
echo '<article>';
// Output city name
echo '<h2>'. get_the_title() .'</h2>';
the_content();
// Output ACF fields
if ( function_exists( 'get_field' ) ) {
// shop image
if ( get_field( 'shop_image' ) ) {
echo wp_get_attachment_image( get_field( 'shop_image' ), 'large' );
}
echo '<div>';
// ACF Shop details
if ( get_field( 'address' ) ) {
the_field( 'address' );
}
if ( get_field( 'phone' ) ) {
echo '<p>'. get_field( 'phone' ) .'</p>';
}
if ( get_field( 'email' ) ) {
echo '<p>'. get_field( 'email' ) .'</p>';
}
// field label 'Hours'
$label = get_field_object( 'hours' );
if ( $label['label'] ) {
echo '<div>';
echo '<h3>'. $label['label'] .'</h3>';
}
if ( get_field( 'hours' ) ) {
the_field( 'hours' );
}
echo '</div>';
echo '</div>';
};
echo '</article>';
}
wp_reset_postdata();
}
echo '</div>';
// ACF upcoming new location fields
if ( function_exists( 'get_field' ) ) {
echo '<article class="new-location">';
if ( get_field( 'new_location_heading' ) ) {
echo '<h2>'. get_field( 'new_location_heading' ) .'</h2>';
}
if ( get_field( 'new_location' ) ) {
echo '<p>'. get_field( 'new_location' ) .'</p>';
}
echo '</article>';
}
endwhile; // End of the loop.
?>
</main><!-- #main -->
<?php
get_footer();