It seems that the team has to answer the question, “Can I have a slider/carousel/etc. in my theme?” almost weekly.
The question is both simple and complex, if such a thing is possible. Stick with me for a moment while I explain. I hope this post helps answer your questions. Please ask any related questions in the comments.
What is a slider?
Sliders are nothing more than some HTML, CSS, and JS. So, when you ask, “Can I have a slider in my theme?” what does that mean? When I read that question, I’m reading, “Can I have some HTML, CSS, and JS in my theme?”
Yes. One hundred times yes.
TRT doesn’t care if you want to have a slider in your theme. Honestly, you can make your entire theme a slider. That’d actually be kind of cool.
You described pretty much what a theme is: HTML, CSS, and JS. That’s the essence of a theme.
The actual question
Most often, the real question is whether you can put some options in your theme such as the following or a variation of it for each slide:
<input> box for the title.
<textarea> for the content.
Theme options isn’t really the best place to save this sort of thing.
All you’re really doing there is creating faux custom post types. If you’re interested in allowing users to create custom content, there’s a wide variety of plugins available for handling such things.
However, there are paths you can go down:
- Allow the user to choose a category/tag/etc. of posts.
- Allow the user to select individual posts/pages.
- Pull media from the media library.
- Make a slider “sidebar” that can be populated with widgets.
This is but a small sampling of ideas off the top of my head.
The difference here is between creating and presenting content. It’s the age-old discussion in which we absolutely stand firm when we say that themes are meant to present content.
The second actual question
Yes, there’s another hidden question in that seemingly innocent question about the slider. It is, “Can I put my slider on the front page?”
First, you must respect the user’s front page settings under Settings > Readings in the admin. If the user has chosen to display their blog posts on the front page, the theme should show blog posts.
It should not show a slider, carousel, and some boxes, burying the blog posts way down at the bottom of the page. Leave that to custom page templates or when a “page” is meant to be shown on the front.
There are exceptions though. You can certainly display the latest blog posts in “slider” format if that’s the design of your theme.
The point here is that it’s not about the slider. It’s about showing the content that the user has explicitly chosen to display on their front page.