Simple Facebook Connect running shortcodes in the head
-
One of my sites had a weird side effect after implementing the Simple Facebook Connect plugin – my custom shortcode was being output in the head of the page as well as in the content.
The page in question is here: http://www.dubrovnikrestaurantkl.com/about/group-bookings. I’ve since disabled SFC so the problem has went away. The image rotator was being outputted on both the head and in the content.
Here is my custom shortcode – perhaps I didn’t code it correctly, which caused the problem?
function dubrovnik_attachment_slider( $atts ) { // get shortcode attributes extract( shortcode_atts( array( 'width' => '460', 'height' => '300', ), $atts ) ); // print images global $post; $args = array( 'order' => 'ASC', 'post_type' => 'attachment', 'post_parent' => $post->ID, 'post_mime_type' => 'image', 'post_status' => null, 'numberposts' => -1, ); $attachments = get_posts($args); if ($attachments) { echo '<div class="attachment-slider" '; // if ( ( $width !== '') && ( $height !== '' ) ) { echo 'style="width:' . $width . 'px; height:' . $height . 'px;"'; // } echo '>'; foreach ($attachments as $attachment) { echo '<img src="' . wp_get_attachment_url($attachment->ID) . '" alt="' . apply_filters('the_title', $attachment->post_title) . '" />'; } echo '</div>'; } // output JS in wp_footer add_action('wp_footer', 'dubrovnik_attachment_slider_js'); function dubrovnik_attachment_slider_js() { ?> <script type="text/javascript"> jQuery(document).ready(function($) { $('.attachment-slider img:gt(0)').hide(); setInterval(function(){ $('.attachment-slider :first-child').fadeOut() .next('img').fadeIn() .end().appendTo('.attachment-slider'); }, 5000 ); }); </script> <?php } } add_shortcode( 'attachment_slider', 'dubrovnik_attachment_slider' );
http://wordpress.org/extend/plugins/simple-facebook-connect/
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Simple Facebook Connect running shortcodes in the head’ is closed to new replies.