WordPress Nivo Slider


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <div id="slider-container" class="grid_16">
  2. <div id="slider">
  3.  
  4. <?php $custom_query = new WP_Query('post_type=slide&orderby=menu_order'); ?>
  5. <?php if ($custom_query->have_posts()): while ($custom_query->have_posts()): $custom_query->the_post(); ?>
  6. <?php $post_id = get_the_ID(); ?>
  7.  
  8. <a href="<?php meta('slide_url'); ?>">
  9. <?php
  10. $image_id = get_post_thumbnail_id();
  11. $image_url = wp_get_attachment_image_src($image_id,'large');
  12. $image_url = $image_url[0];
  13. echo '<img src="' . $image_url . '" title="#caption-slide-' . $post_id . '"/>';
  14. ?>
  15. </a>
  16.  
  17. <?php endwhile; else: ?>
  18. <h2>Sorry...</h2>
  19. <p>No slides to display.</p>
  20. <?php endif; wp_reset_query();?>
  21.  
  22. </div><!-- #slider -->
  23.  
  24. <?php $custom_query = new WP_Query('post_type=slide'); ?>
  25. <?php if ($custom_query->have_posts()): while ($custom_query->have_posts()): $custom_query->the_post(); ?>
  26. <?php $post_id = get_the_ID(); ?>
  27.  
  28. <div id="caption-slide-<?php echo $post_id; ?>" class="nivo-html-caption <?php $text_placement = meta('text_placement'); $class = strtolower($text_placement); echo $class; ?>">
  29. <?php meta('slide_text'); ?>
  30. </div><!-- .nivo-html-caption -->
  31.  
  32. <?php endwhile; else: ?>
  33. <h2>Sorry...</h2>
  34. <?php endif; wp_reset_query();?>
  35.  
  36. <div id="slider-flowers"></div>
  37. </div><!-- #slider-container -->

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.