/
featured-content-slider.php
67 lines (47 loc) · 1.99 KB
/
featured-content-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
59
60
61
62
63
64
65
66
67
<?php
/**
* Featured Post Slider
*
*/
// Get our Featured Content posts
$slider_posts = smartline_get_featured_content();
// Check if there is Featured Content
if ( empty( $slider_posts ) and current_user_can( 'edit_theme_options' ) ) : ?>
<p class="frontpage-slider-empty-posts">
<?php esc_html_e( 'There is no featured content to be displayed in the slider. To set up the slider, go to Appearance → Customize → Theme Options, and add a featured tag in the Post Slider section. The slideshow displays all your posts which are tagged with that keyword.', 'smartline-lite' ); ?>
</p>
<?php
return;
endif;
// Limit the number of words in slideshow post excerpts
add_filter('excerpt_length', 'smartline_slideshow_excerpt_length');
// Display Slider
?>
<div id="frontpage-slider-wrap" class="clearfix">
<div id="frontpage-slider" class="zeeflexslider">
<ul class="zeeslides">
<?php foreach ( $slider_posts as $post ) : setup_postdata( $post ); ?>
<li id="slide-<?php the_ID(); ?>" class="zeeslide">
<?php // Display Post Thumbnail or default thumbnail
if( '' != get_the_post_thumbnail() ) :
the_post_thumbnail('slider_image', array('class' => 'slide-image'));
else: ?>
<img src="<?php echo get_template_directory_uri(); ?>/images/default-slider-image.png" class="slide-image wp-post-image" alt="default-image" />
<?php endif;?>
<div class="slide-entry clearfix">
<?php the_title( sprintf( '<h1 class="slide-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h1>' ); ?>
<div class="slide-content"><?php the_excerpt(); ?></div>
<a href="<?php esc_url(the_permalink()) ?>" class="slide-more-link"><?php esc_html_e( 'Read more »', 'smartline-lite' ); ?></a>
</div>
</li>
<?php endforeach; ?>
</ul>
</div>
<div class="frontpage-slider-controls"></div>
</div>
<?php
// Remove excerpt filter
remove_filter('excerpt_length', 'smartline_slideshow_excerpt_length');
// Reset Postdata
wp_reset_postdata();
?>