Skip to content

Instantly share code, notes, and snippets.

@Giannisduke
Forked from jdcauley/Custom Post Slider
Created October 25, 2017 08:50
Show Gist options
  • Save Giannisduke/c7707bae5fdc53023751fb51d992e84f to your computer and use it in GitHub Desktop.
Save Giannisduke/c7707bae5fdc53023751fb51d992e84f to your computer and use it in GitHub Desktop.
Wordpress Bootstrap Carousel using a custom Post
<div id="myCarousel" class="carousel slide">
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
<li data-target="#myCarousel" data-slide-to="3"></li>
<li data-target="#myCarousel" data-slide-to="4"></li>
</ol>
<div class="carousel-inner">
<?php query_posts('post_type=features&showposts=1'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="active item">
<?php the_post_thumbnail('', array('class' => 'main-home')); ?>
</div>
<?php endwhile; endif; ?>
<?php wp_reset_query(); ?>
<?php query_posts('post_type=features&showposts=4&offset=1'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="item">
<?php the_post_thumbnail('', array('class' => 'main-home')); ?>
</div>
<?php endwhile; endif; ?>
</div>
</div>
<?php wp_reset_query(); ?>
</div>
</div>
<script>
$('.carousel').carousel({
interval: 4000
})
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment