-
Notifications
You must be signed in to change notification settings - Fork 0
/
slider.php
58 lines (57 loc) · 1.42 KB
/
slider.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
<style>
.bx-wrapper{
padding: 60px 0;
}
.bxslider .slide {
width: 80%;
}
.bxslider .bx-controls-direction {
clear: both;
overflow: hidden;
}
.bx-prev {
float: left;
}
.bx-next {
float: right;
}
</style>
<?php // slider_css
/**
* Slider template used for front-page
*/
$featured = query_posts(
array(
'posts_per_page' => $total,
'include' => get_option( 'sticky_posts' ),
'orderby' => 'rand'
)
);
echo '<ul id="my-slider" class="bxslider">';
foreach( $featured as $feature ){
setup_postdata( $feature );
$link = esc_url( get_permalink( get_the_ID() ) );
$cont = sprintf( '<span class="featured-link"><a href="%s">' . __( 'Read: ', 'nopasera' ) . $feature->post_title . '</a></span>', $link );
$postinfo = sprintf( '<h3 class="featured-post">%s</h3><div class="featured-content"><p>%s</p></div>%s', $feature->post_title, get_the_excerpt(), $cont );
printf( '<li><div class="slide">%s</div></li>\n', $postinfo );
}
echo '</ul>';
wp_reset_query();
$featured = (int) count( get_option( 'sticky_posts' ) );
// jQuery code begin for the slider ?>
<script>
( function( $ ){
var slider = jQuery( '.bxslider' );
var slide = jQuery( 'div.slide' );
// begin the slider
slider.bxSlider({
'infiniteLoop': false,
'pagerType': 'short',
'pagerShortSeparator': ' | ',
'minSlides': <?php echo $featured; ?>,
'slideMargin': 100,
'maxSlides': <?php echo $featured; ?>,
});
})( jQuery );
</script>
<?php // end jQuery code