forked from thewirelessguy/cornerstone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathowl.php
87 lines (76 loc) · 2.36 KB
/
owl.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
<?php
/**
* Displays as a slider, all posts from Slider type
* => When Slider post has a thumb : diplays the thum
* => When only Title & Content : The text.
*
*/
$owlsize ="";
if ( ! function_exists( 'cornerstone_owl_init' ) ) {
function cornerstone_owl_init() { ?>
<script type="text/javascript">
jQuery('.cs-owl-init').owlCarousel({
sliderloop:true,
margin:10,
nav:false,
autoplay:true,
loop:true,
autoplayTimeout:5000,
responsive:{
0:{
items:1
},
600:{
items:1
},
1000:{
items:1
}
}
});
</script>
<?php }
}
add_action( 'wp_footer', 'cornerstone_owl_init', 9997 );
?>
<div class="row">
<div id="primary" class="site-content small-12 columns small-centered">
<div id="content" role="main">
<?php
// load Foundation initialisation script in footer
//TODO homlogeneiser owl (cornerstone ou child ? harmoniser avec l'appel de la librairie
$sliderargs = array('post_type' => 'Slider','nopaging'=>'true');
$sliderloop = new WP_Query( $sliderargs );
echo "<div class='cs-owl-init owl-carousel'>";
while ( $sliderloop->have_posts() ) : $sliderloop->the_post();
if(has_post_thumbnail()) {
if($owlsize != '') {
$owlimagethumbnail = wp_get_attachment_image_src( get_post_thumbnail_id(), $owlsize);
$owlimage = $owlimagethumbnail['0'];
} else {
$owlimagefull = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'thumbnail_size');
$owlimage = $owlimagefull['0'];
}
$owlimagealttext = get_post_meta(get_post_thumbnail_id($post->ID), '_wp_attachment_image_alt', true);
$owlcaption = get_post_meta(get_the_ID(), '_owl_meta_box_caption_text', true );
$owllink = get_post_meta(get_the_ID(), '_owl_meta_box_link_text', true );
echo '<div class="item">';
if($owllink != '') {echo '<a href="' . $owllink . '">';}
echo '<img src="'. $owlimage . '" alt="' . $owlimagealttext . '"/>';
if($owlcaption != '') {echo '<div class="owl-caption">' . $owlcaption . '</div>';}
if($owllink != '') {echo '</a>';}
echo '</div>'."\n";
} else {
echo '<div class="item"><h2>';
the_title();
echo '</h2>';
the_content();
echo '</div>';
}
endwhile;
wp_reset_postdata();
echo "</div>";
?>
</div>
</div>
</div>