-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage-brands.php
More file actions
98 lines (85 loc) · 3.37 KB
/
Copy pathpage-brands.php
File metadata and controls
98 lines (85 loc) · 3.37 KB
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
<?php
/*
Template Name: Brands
*/
get_header(); ?>
<?php if (have_posts()): while (have_posts()) : the_post(); ?>
<?php if ( wp_is_mobile() ) {
$img = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large', false, '' ); } else {
$img = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full', false, '' ); } ?>
<div class="hero">
<div class="full-container h-full">
<?php if ( has_post_thumbnail() ) : ?>
<div class="absolute inset-0">
<img class="h-full w-full object-cover" src="<?php echo $img[0]; ?>" alt="">
<div class="absolute inset-0 bg-black/10 bg-gradient-to-t from-black/60 to-transparent"></div>
</div>
<?php endif; ?>
<div class="site-container hero-md">
<article class="lead text-white max-w-3xl">
<?php the_content(); ?>
<?php $link = get_field('link');
if( $link ):
$link_url = $link['url'];
$link_title = $link['title'];
$link_target = $link['target'] ? $link['target'] : '_self';
?>
<a class="btn btn-dark"
href="<?php echo esc_url($link_url); ?>"
target="<?php echo esc_attr( $link_target ); ?>" >
<?php echo esc_html($link_title); ?>
</a>
<?php endif; ?>
</article>
</div>
</div>
</div>
<?php
$terms = get_terms( array(
'taxonomy' => 'brand-category',
'hide_empty' => false,
) );
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) : ?>
<div class="site-container my-12 flex items-center justify-center">
<h4 class="!my-0 !mx-2 text-sm bg-bw-gold text-light border-bw-gold"><?php echo ICL_LANGUAGE_CODE === 'fi' ? 'Näytä kaikki' : 'Show all'; ?></h4>
<?php foreach ( $terms as $term ) : ?>
<a href="<?php echo get_term_link( $term ); ?>">
<h4 class="!my-0 !mx-2 text-sm hover:bg-bw-gold transition-colors duration-500 hover:text-light hover:border-text/30"><?php echo $term->name; ?></h2>
</a>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php
$brands = get_posts( array(
'post_type' => 'brand',
'posts_per_page' => -1,
'orderby' => 'title',
'order' => 'ASC',
) );
if ( $brands ) : ?>
<div class="modules site-container grid md:grid-cols-2 gap-10 lg:gap-16 xl:gap-24 my-16">
<?php foreach ( $brands as $brand ) : ?>
<div>
<?php if ( has_post_thumbnail( $brand->ID ) ) : ?>
<img class="w-full aspect-[3/2] object-cover" src="<?php echo get_the_post_thumbnail_url( $brand->ID, 'medium' ); ?>" alt="">
<?php endif; ?>
<article class="fix py-4 md:py-7">
<?php if (get_the_terms($brand->ID, 'brand-category')): ?>
<a href="<?php echo get_term_link( get_the_terms( $brand->ID, 'brand-category' )[0] ); ?>">
<h4>
<?php echo get_the_terms( $brand->ID, 'brand-category' )[0]->name; ?>
</h4>
</a>
<?php endif; ?>
<h2><a href="<?php echo get_permalink($brand->ID); ?>"><?php echo get_the_title( $brand->ID ); ?></a></h2>
<?php echo apply_filters( 'the_content', $brand->post_content ); ?>
</article>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
<div class="modules">
<?php get_template_part( 'page', 'modules' ); ?>
</div>
<?php endwhile; endif; ?>
<?php get_footer(); ?>