Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // easy SlidesJs gallery adding to wordpress page
- function slides_from_post($atts) {
- extract(shortcode_atts(array(
- "exclude" => '' // parameter to exclude the images you don't want to show
- ), $atts));
- ;
- $tmp = explode(", ", $exclude);
- if ($tmp) {
- foreach ($tmp as $tmpItem) {
- $exclude_array[$tmpItem] = "exclude";
- }
- } else {}
- $attachments = get_children( array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' => 'image') );
- if ($attachments) {
- echo '<div id="slides'.get_the_ID().'" class="inline"><div class="slides_container"><ul>';
- foreach ( $attachments as $attachment_id => $attachment ) {
- if (!$exclude_array[$attachment_id]) {
- echo '<li class="slide">'.wp_get_attachment_image( $attachment->ID, 'medium', 0 ).'</li>';
- }
- }
- echo '</ul><div id="slides"><div class="slides_container">';
- echo '
- <script type="text/javacript">
- jQuery("slides'.get_the_ID().'").slides();
- </script>
- ';
- }
- }
- add_shortcode('slides', 'slides_from_post');
Add Comment
Please, Sign In to add comment