-
Notifications
You must be signed in to change notification settings - Fork 0
/
loop-sponsors.php
63 lines (58 loc) · 1.7 KB
/
loop-sponsors.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
<?php
$sponsor_types = get_terms( array(
'orderby' => 'term_order',
'taxonomy' => 'sponsor_type',
'hide_empty' => true,
) );
echo '<div id="sponsors-loop" class="loop sponsors-loop">';
foreach( $sponsor_types as $sponsor_type ):
echo '<div class="sponsor-type row">';
if( $sponsor_type->slug != 'main-sponsor' ):
echo '<div class="sponsor-type-name col col-12">'.$sponsor_type->name.'</div>';
endif;
$sponsors_args = array(
'post_type' => 'sponsors',
'posts_per_page' => -1,
'tax_query' => array ( array(
'taxonomy' => 'sponsor_type',
'field' => 'slug',
'terms' => $sponsor_type->slug,
'operator' => 'IN'
) )
);
query_posts( $sponsors_args );
if ( have_posts() ):
while ( have_posts() ) : the_post();
if( $sponsor_type->slug == 'main-sponsor' ):
$sponsor_classes = 'col-sm-12 col-md-6 col-lg-6';
$img_class = 'col-12 col-sm-6 col-md-8 col-lg-6';
else:
$sponsor_classes = 'col-sm-6 col-md-4 col-lg-3';
$img_class = 'col-12 col-sm-12';
endif;
echo '<div class="sponsor col col-12 '.$sponsor_classes.' '.$sponsor_type->slug.'">';
if( $sponsor_type->slug == 'main-sponsor' ):
the_excerpt();
endif;
if( has_post_thumbnail(get_the_ID()) ):
$website = get_field( 'website', $post );
if( $website ):
echo '<a href="'.http( $website ).'" target="_blank">';
endif;
echo '<div class="sponsor-thumb row">';
echo '<div class="'.$img_class.'">';
the_post_thumbnail( 'full' );
echo '</div>';
echo '</div>';
if( $website ):
echo '</a>';
endif;
endif;
echo '</div>';
endwhile;
endif;
wp_reset_query();
echo '</div>';
endforeach;
echo '</div>';
?>