Advertisement
nayeemhr

Untitled

Oct 14th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1.  
  2. function stock_carousel_post($atts) {
  3. extract( shortcode_atts( array(
  4. 'count' => -1 ,
  5. 'type' => 'page',
  6. 'custom_css' => '',
  7. ), $atts) );
  8.  
  9. $q = new WP_Query(
  10. array(
  11. 'posts_per_page' => $count,
  12. 'post_type' => 'post',
  13.  
  14. )
  15. );
  16.  
  17. $list = '<div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
  18. <div class="carousel-inner">
  19. ';
  20.  
  21. while($q->have_posts()) : $q->the_post();
  22. $idd = get_the_ID();
  23. $post_content = get_the_excerpt();
  24. $list .= '<div class="carousel-item active" style="width: 100%; height: 150px; background-color: #334;">
  25.  
  26. <div class="carousel-caption d-none d-md-block" >
  27. <h3>'.get_the_title().'</h3><p>'.get_the_content().'</p>
  28. </div>
  29. ';
  30.  
  31. endwhile;
  32.  
  33. $list.= ' </div>
  34. <a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
  35. <span class="carousel-control-prev-icon" aria-hidden="true"></span>
  36. <span class="sr-only">Previous</span>
  37. </a>
  38. <a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
  39. <span class="carousel-control-next-icon" aria-hidden="true"></span>
  40. <span class="sr-only">Next</span>
  41. </a>
  42. </div>';
  43. wp_reset_query();
  44. return $list;
  45. }
  46. add_shortcode('cowse', 'stock_carousel_post');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement