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

Smooth Slider Fix WordPress

  • SOLVED

I have installed Smooth Slider in a site still in testing. Using wp 3.0.4 and the latest version of Smooth Slider.

It works beautifully with one issue. Shortcodes in the content do not execute in the slider. for example the shortcode (in the post) is

[download id=1]

and that's exactly how it appears in the slider rather than the download link it is supposed to create. Image captions also appear as an unrun short code

[caption id="attachment_1127" align="alignleft" width="150" caption="Test test test"][/caption]

rather than just "Test test test"

Is there a way to either run shortcodes inside the slider or hide them altogether. Either solution would be acceptable.

Answers (2)

2011-01-14

Pippin Williamson answers:

Try adding this to your functions.php:


add_filter('the_content', 'do_shortcode');


Connie Taylor comments:

No that didn't work - could I add that to the smooth slider functions?


Pippin Williamson comments:

You can try it, though it should work anywhere.

Are you placing the shortcode for smooth slider inside the post content?


Connie Taylor comments:

No That doesn't work either. I think the smooth slider pulls the content directly from the db but doesn't render it the way a wordpress post does.

The shortcodes do work in the posts and pages so it's not an issue with wordpress - just the slider.


Pippin Williamson comments:

iv.draganov just beat me to it. Just found exactly the same thing. If his doesn't work, here's a slight different version:

Find this line in smooth-slider.php:


$slider_content = $data->post_content;

Then add this line immediately after it:


$slider_content = apply_filters('the_content', $data->post_content);


Pippin Williamson comments:

And keep the filter I gave you earlier.


Connie Taylor comments:

Results are the same as iv.dragonov's solution. At the end of the post I get

Test (0)Test test test

the Test(0) is supposed to be the download link

Test test test is supposed to be the image caption but it appears at the end of the slider content instead of under the image.


Pippin Williamson comments:

Well, we know that the shortcodes are getting executed fine now. The question is why the download link shortcode isn't working. I assume that's the download shortcode from the "Simple Download Manager" plugin?

2011-01-14

Ivaylo Draganov answers:

Adding a filter would not work, because Super Slider is using a custom database query to pull the post data. It's not relying on standard template tags. Applying a filter would be the best approach to solving such an issue but unfortunately that plugin doesn't provide any hooks for filters (e.g. there're no "apply_filters" function call anywhere in the code).

My suggestion would be to dig in the code and try to figure out how exactly it queries for the post content and then modify the code slightly to include a filter (or simple to run it through "do_shortcode").

Hm, try replacing this:

$slider_content = $data->post_content;

with

$slider_content = do_shortcode($data->post_content);


It's in the file <em>smooth-slider.php</em> on lines 560, 736 and 908. I've not tested it but I think it should work.

Cheers


Connie Taylor comments:

I'll reply to this before trying Pippin's latest solution as you posted it first. This is heading in the right direction. the shortcode disappears altogether and is not rendered. The image caption comes out as

"Test(0) Test test test" when it shoud be just "Test test test"


Connie Taylor comments:

I apologize it seems the Test(0) was her download. - there just isn't a link attached to it.


Connie Taylor comments:

Can this be used to just strip out short codes all together? or hide them?


Ivaylo Draganov comments:

<blockquote>Can this be used to just strip out short codes all together? or hide them?</blockquote>

If you want to get rid of them there's a WP function for that - strip_shortcodes. So just use it instead of "do_shortcode":

$slider_content = strip_shortcodes($data->post_content);


A note: it's <em>$data->post_content</em> on line 560 only, on the other lines it's <strong>$post->post_content</strong>

It works on my test site, hope it does the trick for you too =)


Ivaylo Draganov comments:

You could do with a filter (like Pippin suggested) - it would be cleaner and easier to turn on/off. And it would make possible for other functions to hook in (if necessary). Just name the filter hook something other than <em>the_content</em> as that is a WP filter hook name. So something like that in <em>functions.php</em>:

add_filter('slider_content', 'strip_shortcodes');

and in the plugin:

$slider_content = apply_filters('slider_content', $data->post_content);

Happy blogging =)


Connie Taylor comments:

The strip shortcodes did the trick thank you. I think you both contributed to working this out so will be splitting the prize.