Guest User

Untitled

a guest
Sep 26th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. // easy SlidesJs gallery adding to wordpress page
  2. function slides_from_post($atts) {
  3.  
  4. extract(shortcode_atts(array(
  5. "exclude" => '' // parameter to exclude the images you don't want to show
  6. ), $atts));
  7. ;
  8. $tmp = explode(", ", $exclude);
  9. if ($tmp) {
  10. foreach ($tmp as $tmpItem) {
  11. $exclude_array[$tmpItem] = "exclude";
  12. }
  13. } else {}
  14.  
  15. $attachments = get_children( array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' => 'image') );
  16. if ($attachments) {
  17. echo '<div id="slides'.get_the_ID().'" class="inline"><div class="slides_container"><ul>';
  18. foreach ( $attachments as $attachment_id => $attachment ) {
  19. if (!$exclude_array[$attachment_id]) {
  20. echo '<li class="slide">'.wp_get_attachment_image( $attachment->ID, 'medium', 0 ).'</li>';
  21. }
  22. }
  23. echo '</ul><div id="slides"><div class="slides_container">';
  24. echo '
  25. <script type="text/javacript">
  26. jQuery("slides'.get_the_ID().'").slides();
  27. </script>
  28. ';
  29. }
  30. }
  31. add_shortcode('slides', 'slides_from_post');
Add Comment
Please, Sign In to add comment