Mulltiple shortcodes on same page
-
Not sure if this is the right forum, sorry in advance.
I’m trying to do a mouseover change of photos. After help from wp forums I managed to put together a shortcode which actually works. Almost. The problem is when I try to use same shortcode on same page with different parameters it doesn’t work anymore. Shortcode in functions.php is
<?php function roll_me_over_shortcode( $atts ) { $atts = shortcode_atts( array( 'normal' => 'url/to/normal-not-set-photo.jpg', 'hover' => 'url/to/hover-not-set-photo.jpg', 'link' => 'url' ), $atts, 'roll-me-over' ); ob_Start(); ?> <a href="'<?php echo esc_attr( $atts['link'] ); ?>'" target="_top" onmouseover="document.sub_but.src='<?php echo esc_attr( $atts['hover'] ); ?>'" onmouseout="document.sub_but.src='<?php echo esc_attr( $atts['normal'] ); ?>'"> <img src='<?php echo esc_attr( $atts['normal'] ); ?>' style="width:250px; height:250px; border:0px solid #cc3300;" alt="Move your mouse over me" name="sub_but" /> </a> <?php return ob_get_clean(); } add_shortcode( 'roll-me-over', 'roll_me_over_shortcode' );
and when I put only one shortoced per page it works like it should. But if I put two or more it only displays photo, without mouseover change. So when I put
[roll-me-over link="url to page" normal="photo1" hover="photo2"]
it works, but when I put more, so[roll-me-over link="url to page" normal="photo1" hover="photo2"] [roll-me-over link="url to page 2" normal="photo3" hover="photo4"]
it doesn’t work anymore. Any suggestions?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Mulltiple shortcodes on same page’ is closed to new replies.