Skip to content

Instantly share code, notes, and snippets.

@WPDevHQ
Last active August 31, 2016 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WPDevHQ/92a830b5fc541f71dd5700757f95877d to your computer and use it in GitHub Desktop.
Save WPDevHQ/92a830b5fc541f71dd5700757f95877d to your computer and use it in GitHub Desktop.
Generate a bxSlider from a Custom Post Type
<div class="bx-wrapper">
<ul class="bxslider">
<?php
$slider = new WP_Query(array( 'post_type' => 'homepage_slider' ) );
if( $slider->have_posts() ) :
while($slider->have_posts()) :
$slider->the_post();
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' ); ?>
<li class="featured-image" style="background-image: url('<?php echo $thumb['0'];?>')">
<div class="slide-wrapper">
<div class="slide-inner">
<?php the_content() ?>
</div>
</div>
</li>
<?php
endwhile;
endif;
wp_reset_postdata();
?>
</ul><!-- /.bxslider -->
</div><!-- /.bx-wrapper -->
@WPDevHQ
Copy link
Author

WPDevHQ commented Aug 31, 2016

Not sure about the divs - maybe use span instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment