admin管理员组文章数量:1392003
i am creating a carousel using WP Bakery Page Builder which should show posts from two different post types (one is custom). Is there any plugin to get a workaround, or perhaps any suggestion?
i am creating a carousel using WP Bakery Page Builder which should show posts from two different post types (one is custom). Is there any plugin to get a workaround, or perhaps any suggestion?
Share Improve this question asked Mar 11, 2020 at 12:58 Pranav VaidPranav Vaid 11 Answer
Reset to default 1Multiple Post type in one slider Shortcode
Using This Shortcode For Owl Carousel In Your Page And Add Your Custom Post Type In The Arguments of Query
Put This Code in Your functions.php
add_action( 'wp_enqueue_scripts', 'my_child_enqueue_styles' );
function my_child_enqueue_styles()
{
wp_enqueue_style('styleowl','https://cdnjs.cloudflare/ajax/libs/OwlCarousel2/2.0.0-beta.2.4/assets/owl.carousel.min.css');
wp_enqueue_style('style1','https://cdnjs.cloudflare/ajax/libs/OwlCarousel2/2.0.0-beta.2.4/assets/owl.theme.default.min.css');
wp_enqueue_script('pro-owl','https://cdnjs.cloudflare/ajax/libs/OwlCarousel2/2.3.1/owl.carousel.min.js',array( 'jquery' ), '', false);
wp_enqueue_script('jquery','https://cdnjs.cloudflare/ajax/libs/jquery/3.4.1/jquery.min.js',false);
}
add_shortcode('post_slider','custom_slider');
function custom_slider(){
$args = array(
'post_type' => array('post','events'), // add to your multiple post type in the array
'post_status' => 'publish',
'posts_per_page' => -1,
);
$arr_posts = new WP_Query( $args );
if ( $arr_posts->have_posts() ) :
ob_start(); ?>
<div class='product-carousel'>
<div class="owl-carousel themes-p" id="product">
<?php
while ( $arr_posts->have_posts() ) :
$arr_posts->the_post();
?>
<div class="item list-porduct">
<div class="product_image">
<a href="<?php the_permalink() ?>">
<?php the_title(); ?>
<?php the_post_thumbnail('medium'); ?>
</a>
</div>
</div>
<?php
endwhile;
?>
</div>
</div>
<?php endif; ?>
<style type="text/css">
.owl-prev {
width: 15px;
height: 100px;
position: absolute;
top: 0%;
outline: none;
transform: translateY(95%);
margin-left: -20px;
display: block !important;
}
.owl-next {
outline: none;
width: 15px;
height: 100px;
position: absolute;
top: 0%;
transform: translateY(95%);
right: -20px;
display: block !important;
}
.owl-prev span {
position: absolute;
color:red;
width: 34px;
height: 36px;
left:20px;
font-size: 40px;
line-height: 32px;
}
.owl-next span {
position: absolute;
color:red;
width: 34px;
height: 36px;
right:20px;
font-size: 40px;
line-height: 32px;
}
</style>
<script type="text/javascript">
jQuery('#product').owlCarousel({
autoplay:true,
items: 5,
nav: false,
loop:true,
dots: false,
margin:10,
mouseDrag: true,
responsiveClass: true,
responsive: {
0:{
items: 1
},
480:{
items: 1
},
769:{
items: 2
},
1024:{
items: 4
},
1440:{
items: 4
},
}
});
</script><?php}
- Add This [post_slider] shortcode in Your page Builder Text Element
本文标签: pluginsposts from multiple post types in one slider
版权声明:本文标题:plugins - posts from multiple post types in one slider 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744675245a2619069.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论