Created
September 29, 2018 18:58
-
-
Save Rayhanuc/5a0b8c903d9a31608e96073f1452c0f6 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
//industry_rayhan_slide_shortcode start | |
function industry_rayhan_slides_shortcode($atts){ | |
extract( shortcode_atts( array( | |
'count' => 2, | |
'type' => 'page', | |
), $atts) ); | |
$arg = array( | |
'post_type' => 'industry-slide', | |
'posts_per_page' => 3, | |
); | |
$get_post = new WP_Query($arg); | |
$slider_rendom_number = rand(6982887, 74634636); | |
$industry_slides = ' | |
<script> | |
jQuery(window).load(function() { | |
jQuery("#industry-slides-'.$slider_rendom_number.'").owlCarousel({ | |
items: 1, | |
loop: true, | |
dots: true, | |
nav: true, | |
navText: ["<i class=\'fa fa-angle-left\'></i>","<i class=\'fa fa-angle-right\'></i>" ], | |
autoplay: false | |
}); | |
}); | |
</script> | |
<div id="industry-slides-'.$slider_rendom_number.'" class="owl-carousel industry-slides">'; | |
while ($get_post->have_posts()) : $get_post->the_post(); | |
$post_id = get_the_ID(); | |
$industry_slides .= ' | |
<div style="background-image:url('.get_the_post_thumbnail_url($post_id, 'large').')" class="industry-single-slide"> | |
<div class="industry-single-slide-inner"> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-md-6"> | |
<h2>'.get_the_title($post_id).'</h2> | |
'.wpautop(get_the_content($post_id)).' | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
'; | |
endwhile; | |
$industry_slides .= '</div>'; | |
wp_reset_query(); | |
return $industry_slides; | |
} | |
add_shortcode('industry_slides', 'industry_rayhan_slides_shortcode'); | |
//industry_rayhan_slides_shortcode end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment