Created
          February 17, 2018 08:14 
        
      - 
      
- 
        Save salehahmadbabu/baa010e8c1ca40cd8713bf12a7dc081b to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| function stock_slides_shortcode($atts){ | |
| extract( shortcode_atts( array( | |
| 'count' => '', | |
| ), $atts) ); | |
| $q = new WP_Query( | |
| array('posts_per_page' => -1, 'post_type' => 'slide') | |
| ); | |
| $list = ' | |
| <script> | |
| jQuery(window).load(function(){ | |
| jQuery(".stock-slides").owlCarousel({ | |
| items:1, | |
| loop: true, | |
| nav:true, | |
| autoplay: false, | |
| dots: true, | |
| navText: ["<i class=\'fa fa-angle-left\'></i>", "<i class=\'fa fa-angle-right\'></i>"] | |
| }); | |
| }); | |
| </script> | |
| <div class="stock-slides">'; | |
| while($q->have_posts()) : $q->the_post(); | |
| $idd = get_the_ID(); | |
| $slide_meta = get_post_meta($idd, 'stock_slide_options', true); | |
| $post_content = get_the_content(); | |
| $list .= ' | |
| <div style="background-image: url('. get_the_post_thumbnail_url( $idd, 'large' ).')" class="stock_slide_item"> | |
| <div class="stock-slide-table"> | |
| <div class="stock-slide-tablecell"> | |
| <div class="container"> | |
| <div class="row"> | |
| <div class="col-md-6"> | |
| <h2>'.get_the_title( $idd ).'</h2> | |
| '.wpautop( $post_content ).''; | |
| if(!empty($slide_meta['buttons'])){ | |
| $list .= '<div class="stock-slide-buttons">'; | |
| foreach ($slide_meta['buttons'] as $button) { | |
| $btn_link = ($button['link_type'] == 1) ? get_page_link($button['link_to_page']) : $button['link_to_external']; | |
| $list .= '<a href="'.$btn_link.'" class="'.$button['type'].'-btn stock-slide-btn">'.$button['text'].'</a>'; | |
| } | |
| $list .= '</div>'; | |
| } | |
| $list .= ' | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| '; | |
| endwhile; | |
| $list.= '</div>'; | |
| wp_reset_query(); | |
| return $list; | |
| } | |
| add_shortcode('stock_slides', 'stock_slides_shortcode'); | |
| ?> | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment