Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

do_shortcode not working WordPress

  • SOLVED

I've got a NextGen Gallery (with Smooth Gallery) that I need to keep out of the edit box. So I want to install the shortcode on a page template. The code that's meant to do that is:

<?php echo do_shortcode("[smooth=id:1; width:650; height:400; timed:true; arrows:false; carousel:false; links:false; info:true; frames:false; delay:8000; transition:fade;]"); ?>

But it's not working. It returns what's inside the quotes, brackets and all, but does not show me the gallery.

Any ideas?

UPDATE: appears to be a bug in Smooth Gallery plugin. But if anyone knows a fix/workaround, I'd love to know it. Thanks!

Answers (3)

2010-04-28

Dan Fraticiu answers:

That is not a shortcode, I know it looks like one but it's really not. You can use this instead:

<?php apply_filters( 'the_content', '[smooth=id:1; width:650; height:400; timed:true; arrows:false; carousel:false; links:false; info:true; frames:false; delay:8000; transition:fade;]'); ?>


Good luck

2010-04-27

Milan Petrovic answers:

What's inside the function all is returned by do_shortcode function if there are no shortcodes defined in WordPress. Adn this can happen if you are making a call before the plugins executed their actions (usually before init()), or plugin didn't registered shortcode in the first place. Without debugging I can't tell you exactly what is the cause.

2010-04-27

itshameem answers:

your problem is not so clear to me but i can give you some example of using do_shortcode

here is some code-
its a sample use of shortcode
<?php
$product_id = get_post_meta($post->ID, 'product_id, true);
echo do_shortcode("[product id='$product_id']");
?>


If you want a specific gallery to display a configuration other than your default one, you can use:
[smooth=id:xx; width:xx; height:xx; timed:xx; delay:xx; transition:xx; arrows:xx;
info:xx; carousel:xx; text:xx; open:xx; links:xx; margin:; align:;]

here,
<blockquote> id: The id you were already using on [ gallery=id ]
width: Width of your image container
height: Height of your image container
timed: true/false to slideshow your images
delay: Time in miliseconds before moving to the next image
transition: Animation when moving to the next image: fade, fadeslideleft,
continuoushorizontal, continuousvertical, crossfade, fadebg
arrows: true/false to see the arrows for next/previous images
info: true/false to show the image description
carousel: true/false to see all thumbnails
text: Text relative to the Carousel
open: true/false to show the carousel opened/closed
links: true/false to click on the image and open the original image alone
margin: Distance from the gallery border to the text
align: Gallery alignment: left, right, center, float_left, float_right</blockquote>

In your case, you can use any option above and in any order:
[smooth=id:xx; arrows:true; carousel:true; links:true; width:500; height:300;]

There might be some compatibility issue.. For compatibility with old versions, you can also use:
[smooth=galleryId, width, height, timed, arrows, carousel, links]
Ex.
[smooth=12345, 400, 400, false, true, true, true]