My First Plugin – HELP
-
I’m building a gallery plugin. It allows users to use a shortcode to display the gallery. I have one problem. When a user puts the shortcode in the middle of the content, the gallery ignores that and shows up at the top of the content.
Here is my (cleaned up from html) code:
<?php function wp_gallery($width = '', $height = '', $resize = 'no', $echo = true) { global $post, $id; $galleria_options = get_option('galleria_options'); $width = intval($galleria_options['width']); $height = intval($galleria_options['height']); $resize = intval($galleria_options['resize']); $images =& get_children( 'post_type=attachment&post_mime_type=image&post_parent=' . get_the_id() ); if ( empty($images) ) { echo "There are no images attached to this post."; } else { ?> <?php foreach( $images as $imageID => $imagePost ){ $src = wp_get_attachment_image_src($imageID, 'medium', true); $img = $src[0]; if ( $resize == 1 ) { echo '<li class="active"><img src="' . WP_PLUGIN_URL . '/wp-galleria/img/thumb.php?src='. $img .'&h='. $height .'&w='. $width .'&zc=1" alt="'. get_the_title($imagePost) .'" title="'. get_the_title($imagePost) .'" width="'. $width .'" /></li>'; } else { echo '<li class="active"><img src="'. $img.'" alt="'. get_the_title($imagePost) .'" title="'. get_the_title($imagePost) .'" /></li>'; } } ?> <?php } } ### Shortcode add_shortcode("gallery", "wp_gallery"); ?>
What can be wrong? Thanks very very much.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘My First Plugin – HELP’ is closed to new replies.