Skip to content

Instantly share code, notes, and snippets.

@gicolek
Created December 6, 2012 22:48
Show Gist options
  • Save gicolek/4229191 to your computer and use it in GitHub Desktop.
Save gicolek/4229191 to your computer and use it in GitHub Desktop.
Sample WP_Query
<?php
$args = array(
'post_type' => 'slider',
'posts_per_page' => -1,
);
$slider_query = new WP_Query( $args );
?>
<?php if ( $slider_query->have_posts() ): ?>
<?php while ( $slider_query->have_posts() ): $slider_query->the_post(); ?>
<?php if ( has_post_thumbnail() ): ?>
<?php the_post_thumbnail( 'slider' ); ?>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment