Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function matter_slider_shortcode_function() {
- $wp_query = new WP_Query( array(
- 'post_type' => 'wpb_main_slider',
- 'orderby' => 'menu_order',
- 'order' => 'ASC'
- ));
- $wpb_slide_count = $wp_query->post_count;
- ob_start();
- ?>
- <?php if ($wp_query->have_posts()){ ?>
- <div id="carousel-area">
- <div id="carousel-slider" class="carousel slide" data-interval="5000">
- <div class="carousel-inner">
- <?php while ($wp_query->have_posts()) : $wp_query->the_post();?>
- <?php global $post; ?>
- <?php $wpb_matter_slider_background = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );?>
- <div class="item <?php if( $wp_query->current_post == 0 ):?>active<?php endif; ?>" style="background-image: url('<?php echo $wpb_matter_slider_background[0]; ?>');">
- <div class="carousel-caption">
- <h1 class="animated-late fadeInDown"><?php the_title();?></h1>
- <h2 class="animated-late fadeInLeft delay-1"><?php the_content();?></h2>
- <a class="btn btn-large btn-common-white animated fadeInDown delay-1-5" href="#"><i class="fa fa-check"></i> Get Started</a>
- <a class="btn btn-border btn-large animated fadeInDown delay-1-8" href="#"><i class="fa fa-coffee"></i> Learn More</a>
- </div>
- </div>
- <?php endwhile; ?>
- </div>
- <?php if($wpb_slide_count > 1):?>
- <a class="left carousel-control animated fadeInLeft" href="#carousel" data-slide="prev"><img src="<?php echo get_template_directory_uri();?> /img/slider/btn-prev.png" alt="previuos button"></a>
- <a class="right carousel-control animated fadeInRight" href="#carousel" data-slide="next"><img src="<?php echo get_template_directory_uri();?>/img/slider/btn-next.png" alt="next button"></a>
- <?php endif; ?>
- </div>
- </div>
- <?php
- }
- else{
- _e( '<h2>'.'No Post Found For Slider.'.'</h2>', 'wpb_theme' );
- }
- wp_reset_postdata(); // Reset
- return ob_get_clean();
- }
- function matter_slider_register_shortcodes(){
- add_shortcode('matter-slider', 'matter_slider_shortcode_function');
- }
- add_action( 'init', 'matter_slider_register_shortcodes');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement