Advertisement
imranmodel32

Bootstrap carousel shortcode snipate

Aug 10th, 2014
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. function matter_slider_shortcode_function() {
  2. $wp_query = new WP_Query( array(
  3. 'post_type' => 'wpb_main_slider',
  4. 'orderby' => 'menu_order',
  5. 'order' => 'ASC'
  6. ));
  7. $wpb_slide_count = $wp_query->post_count;
  8.  
  9. ob_start();
  10. ?>
  11. <?php if ($wp_query->have_posts()){ ?>
  12. <div id="carousel-area">
  13. <div id="carousel-slider" class="carousel slide" data-interval="5000">
  14. <div class="carousel-inner">
  15.  
  16. <?php while ($wp_query->have_posts()) : $wp_query->the_post();?>
  17. <?php global $post; ?>
  18. <?php $wpb_matter_slider_background = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );?>
  19.  
  20. <div class="item <?php if( $wp_query->current_post == 0 ):?>active<?php endif; ?>" style="background-image: url('<?php echo $wpb_matter_slider_background[0]; ?>');">
  21.  
  22. <div class="carousel-caption">
  23. <h1 class="animated-late fadeInDown"><?php the_title();?></h1>
  24. <h2 class="animated-late fadeInLeft delay-1"><?php the_content();?></h2>
  25. <a class="btn btn-large btn-common-white animated fadeInDown delay-1-5" href="#"><i class="fa fa-check"></i> Get Started</a>
  26. <a class="btn btn-border btn-large animated fadeInDown delay-1-8" href="#"><i class="fa fa-coffee"></i> Learn More</a>
  27.  
  28. </div>
  29. </div>
  30.  
  31. <?php endwhile; ?>
  32.  
  33. </div>
  34.  
  35.  
  36. <?php if($wpb_slide_count > 1):?>
  37.  
  38. <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>
  39. <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>
  40.  
  41. <?php endif; ?>
  42. </div>
  43. </div>
  44.  
  45. <?php
  46. }
  47. else{
  48. _e( '<h2>'.'No Post Found For Slider.'.'</h2>', 'wpb_theme' );
  49. }
  50. wp_reset_postdata(); // Reset
  51. return ob_get_clean();
  52. }
  53.  
  54. function matter_slider_register_shortcodes(){
  55. add_shortcode('matter-slider', 'matter_slider_shortcode_function');
  56. }
  57.  
  58. add_action( 'init', 'matter_slider_register_shortcodes');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement