Skip to content

Instantly share code, notes, and snippets.

@FernE97
Created March 6, 2012 23:02
Show Gist options
  • Save FernE97/1989620 to your computer and use it in GitHub Desktop.
Save FernE97/1989620 to your computer and use it in GitHub Desktop.
PHP: WordPress Slides
<ul class="slides">
<?php
$args = array(
'post_type' => 'slide',
'orderby' => 'menu_order',
'order' => 'ASC',
'posts_per_page' => 3
);
$slides = get_posts( $args );
$count = 0;
$slide_total = count( $slides );
foreach ( $slides as $post ) {
$count++;
$image_thumb = wp_get_attachment_image( get_post_thumbnail_id( $post->ID ), 'slide' );
?>
<li id="slide-<?php echo $count; ?>" class="slide">
<?php echo $image_thumb; ?>
<div class="slide-content">
<h2><?php echo $post->post_title; ?></h2>
<?php echo $post->post_content; ?>
</div>
<span class="slide-number"><?php echo $count, ' of ', $slide_total; ?></span>
</li>
<?php
}
?>
</ul><!-- /slides -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment