If you want to integrate a SmoothGallery into your theme you can use the WordPress SmoothGallery plugin. There’re two ways to do this:
- You want a gallery in your sidebar? Use the widget.
- You want a gallery somewhere in your theme? Follow the developer howto.
Sidebar widget
The plugin comes with a widget that displays a gallery in your sidebar. This way it’s very easy to insert a gallery because you don’t need to know how to write PHP code. Since the widget renders the gallery inside an iFrame you can add as many galleries as you want.
Developer Howto
All you have to do is to implement the function insertSmoothGallery in the file config.php; you can find that file under wp-content/plugins/smoothgallery. Depending on your implementation the plugin makes sure that the CSS and JavaScript will be included inside your page.
Let’s say you want a timed gallery on the page with the id 4711 somewhere in your theme that’s 400×80 pixels. Open the file config.php and implement the insertSmoothGallery function like this:
function insertSmoothGallery() { # add all the conditional tags you're using to the array if (assert_functions_exist(array('is_page')) === false) return false; if (is_page('4711')) { return array('width' => 400, 'height' => 80, 'timed' => 'true'); } return false; }
Once you’ve done that put the HTML markup for the gallery somewhere inside your theme and you’re all set. No matter how you implement the function don’t remove the call to assert_functions_exist.
As you can see, I used the conditional tag is_page. These come in handy if you’d like to display the gallery on some specific pages only - if you don’t want that but a gallery on each and every page just remove the if statement and the corresponding curly brackets.
Just add another sidebar…
Instead of implementing the clumsy insertSmoothGallery function you can simply add another sidebar to your theme if you like that better. Think of it as a placeholder for widgets. It doesn’t necessarily have to be a vertical bar on the side - some horizontal thing in your header or footer is okay too.
So, maybe you want to have a look at the Widgets API and learn how to add another sidebar to your theme. Check out register_sidebar and dynamic_sidebar in particular; the page about the second function tells you how to manage Multiple Sidebars in your theme.
38 comments ↓
Hi Christian, this is a sweet plugin, exept I cannot activate it as I get the
“Plugin could not be activated because it triggered a fatal error.”
Message.
I’ve tried deactivting all my other plugins, and checked for the call to the header and footer, but no luck.
Any ideas what the problem might be?
Hi Danny,
please have a look at this comment.
Great plugin but I can’t get it to work. What am I not doing?
I’ve uploaded the plugin and activated it, but when i put
in to my Main Index Template all that shows up on my page is the actual words and it doesn’t show the plugin.
Hi Paul,
you’ll have to edit the file
smoothgallery.phpthat comes with the plugin. Open it and search for the functioninsertSmoothGalleryand insert your code there.Thanks for the quick reply but when I went in the smoothgallery.php file and changed the first function that says return false to the code above I still get the same problem.
This looks like a simple solution, but when I load my index page I get a big white blank where the image should be.
You can see it here … http://www.bodycreativenetwork.com
Any help would be greatly appreciated, thanks!
Ok I edited the smoothgallery.php already, plugin activated already and how to insert smoothgallery.php in my index.php?
Do I have to put include smoothgallery.php? how do you do it?
Hi mas,
This video shows you how I did it.
Activate the plugin, implement
insertSmoothGallery, insert the markup in your theme and you’re done. If it still doesn’t work read the FAQ or write me an e-mail.Hello Christian,
Thanks for providing us with this plug-in which we can use. I have a question though regarding integrating the plug-in within the site for the latest articles.
On my home page, I currently have a tabbed feature where my latest article is displayed. What I would like to do is replace that with the SmoothGallery plug-in so that it would grab the three most recent articles and their related images.
I was trying to use the code from your example on the front page, and wrapping that around the existing code in my theme which displays the latest article, but with no luck. Can you provide us with a way to integrate the plug-in in that fashion? Or at least point us in the right direction?
Thanks.
Hi everybody,
This should be the feature you were looking for…
When you say “put the code for the gallery somewhere on your page” which code is that? Thanks!
Hi Justin,
That’s the HTML markup for the gallery. Thanks for the hint!
What about using a gallery on one page only? I have mine on the front page but no where else. It works fine without error on this page. I used conditional wordpress tags in smoothgallery.php.
All other pages give the error: invalid argument supplied for foreach() ….[file location] smoothgallery.php on line 94. This line is looking for key values but finds none since the gallery is only on the one page.
What do I add to smoothgallery.php to avoid this little error?
Answering my own question…
in smoothgallery.php: make sure you double check your work when adding function insertSmoothGallery. Don’t change return false;.
(implementing smooth gallery into theme)
I tired to enter the code below into my wp-config.php file. Because of a statement below the code, according to the instructions as to how I understand it. I didn’t see a config.php file so I used the wp-config.php file. I also installed the smoothgallery files into my plugin directory.
Now I just get this message when I get to my site.
Parse error: syntax error, unexpected ‘}’ in /home/jaxel/public_html/sodafox/sodafoxblog/wp-config.php on line 28
(code inserted)
function insertSmoothGallery() {
return array(’width’ => 400,
‘height’ => 50,
‘timed’ = ‘true’);
}
(instructions)
If you want to integrate a SmoothGallery into your theme you can use the WordPress SmoothGallery plugin. All you have to do is to implement the function insertSmoothGallery in the file config.php.
Hi Irene,
have a look at the directory
wp-content/plugins/smoothgallery: you’ll find aconfig.phpthere. Insert your code into this file.Hi Christian,
Thanks for this fab plug in! I’m just having trouble getting it to work. I amended the congif.php file in the smoothgallery folder:
And then I inserted this code in my home.php file
And it is coming up with just words on the page. See http://corkermag.com/blog/
What am I doing wrong?
Thanks in advance.
Ok, there is some serious misunderstanding on my part.
I am trying to install the plugin on my home page and I get nothing.
Here is what I did:
1. uploaded & activated the plugin
2. added this code to the config file (in the plugin directory):
3. placed this in my header file:
insertSmoothGallery();4. in homepage file:
insert_recent_images_box(5);5. created a test post with an image.
Nothing displays on the home page. I want the carousel to display the images from the last 5 posts.
What am I missing?
Thanks.
Hi Steve,
step three isn’t necessary. Have you used WordPress’ built-in Media Library to upload and attach the image to the post? Have you tried using the special tag inside the post? Does the latter work?
Hi, Christian. Is this version compatible with WP 2.0?
And is there a “Gallery Set” function?
Thanks a lot from Ukraine
Hi Zolud,
I haven’t tested the plugin with WP 2.0 but just give it a try
If you want images from some set in a gallery you have two options:
Since the second option currently doesn’t work and if you’re using WP 2.0 you won’t have the “Media Library” (do you?), so option one isn’t possible either. I suggest, that you update WP to 2.5 or wait until I’ve included support for images from Flickr.
Hi Christian,
I’m experiencing a bug in FireFox. The gallery loads, there’s a black flash on the screen, then the first image fades to white before the second loads without the fade transition.
The page is the link I’ve set in the website field in this comment form. I’ve got the gallery loading as part of my theme so I haven’t included the smoothgallery custom field.
Any ideas?
Cheers,
Robert
Hi Robert,
hm strange, I can’t see the error here and I’ve tried it with Firefox (2.0.0.14) and Safari (3.1.1): the transition looks fine for me. I’m sorry, but I can’t help you with that.
BTW: If you’ve integrated the gallery into your theme with the
insertSmoothGalleryfunction, you don’t need the custom field. So that should be okay.Hi!
I was looking for a plugin that will show images in a nice way and I was glad I stumbled on your plugin. I want to integrate nextgen smooth gallery in the theme. I’m not a coder so I rely on cut-and-paste instructions.
But I was stumped with the how to on integrating it with the theme.
First, the plugin directory of the site I’m working on looks like this…
mydomain.com/wp-content/plugins/nextgen-smooth-gallery/
Do we have to rename the nextgen-smooth-gallery folder to smoothgallery?
Inside the nextgen-smooth-gallery folder are the following:
1. /smoothgallery ==> another folder
2. nggsmooth.php
3. nggsmoothframe.php
4. nggsmoothsharedfunctions.php
5. readme.txt
Inside the /smoothgallery folder are the following:
1. /CSS ==> another folder with images and CSS.
2. /Scripts ==> a folder with JavaScript files only.
3. License.txt
My best bet for what passes as config.php is nggsmooth.php so I placed the function insertSmoothGallery there above all the other functions. My dashboard went blank. I also watched the videos.
BTW, I have NextGen itself installed and running. Fact, the the images are showing great in the plugin settings page. If I can only make it appear on the front page… this is embarrassing but I’m also lost on the HTML mark-up to insert the gallery into the index.html or home.php.
Thanks.
Hi Bong,
this plugin is just about SmoothGallery - if you’d like to integrate SmoothGallery with NextGen, you should ask these guys.
However, if you decide to use this plugin I will of course help you to integrate it on your website; just write me an email.
Hi Christian,
I am integrating this into my theme, but it displays the box with the arrow but no image. I am so close! I have checked the path to the image and it’s there. I am stumped. If you have any ideas I would really appreciate it.
-Gregg
Hey Christian
Nice Plug-In you got going here. I’m trying to install it, but once I do all the steps you’ve put in the instructions I get no change visible. I’ve activated the plug-in, and pasted the markup text in the main index template so that it would show up after the header. I then went into the config.php, saw this
Which I then replaced with this
I am getting this error on ALL my pages and blog posts:
Fatal error: Call to undefined function insertsmoothgallery() in wp-content\plugins\smoothgallery\smoothgallery.php on line 94
I have added the code to
config.php:The plugin seems to be breaking the
wp_header()code on WordPress 2.6.1.Hey man thanks for the great plugin.
im having some trouble with installation.. i did everything youve requested (im trying to include the plugin as part of my theme on the home page i.e. display featured posts) and you keep mentioning insert the HTML markup in the header.
Could you please tell me WHAT html markup? im new to programming so i have no idea how to call the plugin on my home page?
PS i think a lot of people are trying to use this to display their featured posts… maybe a tutorial just on that???
thanks!
That’s a great plugin however I am having a bit of an issue. I installed it and played with the plugin enough to have it work (that’s what I thought!).
The plugin displays the images and everything but I get an error message at the top and bottom of my page saying:
Warning: Invalid argument supplied for foreach() in /home/.minni/xxxxxx/iphonedownloadblog.com/wp-content/plugins/smoothgallery/smoothgallery.php on line 97
Line 97 is : foreach ($parameters as $key => $value) {
I really don’t know what to do here.
Any help would be greatly appreciated. Thanks
Hi Sebastien,
if you changed the
insertSmoothGalleryfunction and it doesn’t returnfalseor an array that holds the options for the gallery, theforeachstatement will break apart.Just replace this function with the original one and everything should be okay. If you want to integrate the gallery into your theme and you want to change that function make sure to either return an array or
false.Thanks for the quick reply
I do web design & coding for a living and I have to say the instructions here are not the clearest I have ever seen. If I struggled to get this working, I can only imagine how many newbs get frustrated and go onto some other plugin.
This is an excellent plugin and looks great, so here are the instructions to get it working:
/wp-content/plugins/smoothgallery/config.phpand at the bottom find this:function insertSmoothGallery()… and change it so that it looks like this:Of course, you can change the settings to your needs and image size.
The reason I struggled to get it to work was that I had
ShowCarousel, which was not correct and I happen to come across the correct variable (Carousel). Before I changed that variable I got zip, nada, nothing displaying although I could see that the code found the images ok. I even revertedconfig.phpto its original state and my 5 images would display, stacked. I knew the problem had to be a setting in the plugin.Hope this helps the next person.
I must be very stupid. I have attempted to add this plugin and get it to work. I believe I followed the directions: I have WP version 2.3.1. I uploaded the plugin to my plugins folder. I then activated it.
Herein lies the problem. I do a test post. I add a couple of images and the plugin does not provide the code until I save. So I save and I follow all the directions in your video: I add the custom field and implement the shortcode. I’ve added the html generated code also and still, It won’t work. If there’s something else I need to do to the files, please tell me step by step because I’m not a programmer.
But I get this error:
Warning: Invalid argument supplied for foreach() in /home/content/e/f/o/efoliomn/html/wp-content/plugins/smoothgallery/utils.php on line 357
I don’t know what to do. Please help.
Hi Kat,
No you’re not
I’m sure that we’ll get this working!
Can you e-mail me a link to your test post? I’ll have a look at your page to see what might be wrong.
PS.: The error should be fixed in version 1.11.2.
Once I add images to a post or page I just get “There aren’t any images attached here” where the code is meant to be.
Hi Christiaan,
After adding the images you’ll have reload the edit screen. The SmoothGallery panel under Advanced Options won’t pick up the images until you hit reload in your browser or click Save. There’s no AJAX magic involved here.
I have a weird problem where the smoothgallery.php css returns a 404. If I remove the ‘prefix’ get parameter, it works ok.
Any ideas?
Just to clarify the statement above, it’s the css link to the css code (smoothgallery.php) the plugin inserts in the head section of my html that I discovered was returning the 404.
Leave a Comment