Community Forums › Forums › Archived Forums › General Discussion › Slider to show on certain category
- This topic has 9 replies, 2 voices, and was last updated 10 years, 7 months ago by
Brad Dalton.
-
AuthorPosts
-
April 23, 2013 at 10:13 am #37168
etchattic
MemberHi all
Does anyone know of a slider / Banner plugin that allows the banner to change depending on what category the page is.
Say I click on a post called dogs collar and that post falls under the category of dogs. The banner would be specifically for a dog slider. If I clicked cats treats the category would be cats and show the cats slider.
Thanks for any feedback in advance
-Craig-
April 23, 2013 at 10:42 am #37176Brad Dalton
ParticipantYes and there's many ways to do this which i have already written about.
Just to clarify, you want to display a custom header image (What you call a banner) which is different for each category archive?
Or display a custom header depending on what category the posts are assigned to.
Example:
All posts under the category DOGS will display one specific header image for that categories posts.
You can use:
1. A plugin
2. CSS Code
3. PHP with conditional tags
April 23, 2013 at 10:50 am #37178etchattic
MemberThanks Brad
"Or display a custom header depending on what category the posts are assigned to." that is spot on as long as the custom head section makes the slider category = the post/page category.
It would be multiple sliding images using a slider plugin.
I was thinking the slider could have the same category as the post/ page category and with PHP you could assign that the category of the slide and the post/page must = but if there is no match the home page slider will show.
Hope that made sense. I'm pretty new when it comes to PHP but I've been getting my hands dirty and am amazed at what can be achieved, so would like to go the PHP route. If you know of any tutorials and could point me in the right direction that would be awesome.
Thanks again for the quick response
April 23, 2013 at 11:18 am #37187Brad Dalton
ParticipantAwesome, Most people go the plugin route which is too easy.
Got heaps of code snippets and tutorials on how to do this.
Firstly, you can use PHP with a conditional tag and hook it into the header or any other hook location.
You'll need to create a different slider for each category and then upload images for that category (simple).
That will then give you a list of shortcodes or PHP with different i.d's which you can use in your custom functions as shown above.
Change the conditional tag for is_category('i.d here') in the code and thats basically it.
Not difficult.
Or you can use multiple conditionals in the one function
Code not displaying? Grab it on Github.
April 23, 2013 at 11:36 am #37192etchattic
MemberBrad your a legend
Just checked your wpsites site now. I think I have just stumbled upon the holy grail of code snippets.
Thanks I really appreciate the help
Craig
April 23, 2013 at 11:43 am #37196Brad Dalton
ParticipantApril 23, 2013 at 11:48 am #37198etchattic
MemberOne thing
Is it not possible to make the category of the page automatically call the category of the slider. Say for instance a Client adds a new category, that category wouldn't be in the conditional functions and would have to be manually coded.
Craig
April 23, 2013 at 12:02 pm #37199Brad Dalton
ParticipantPretty much anything is possible with PHP. It would require a bit more than what's in my code snippets as they're basic custom functions with different conditional tags and Genesis hooks.
Not sure of your level but here's a good beginners guide to PHP http://devzone.zend.com/4/php-101-part-1-down-the-rabbit-hole/
April 23, 2013 at 12:08 pm #37201etchattic
MemberI'm a total greenhorn, cutting and pasting with tweeks and workarounds to get things going but I can see the light at the end of the tunnel. To be honest I'm needing to step up and get a deeper understanding, fortunately it always seems like I have to much work and not enough time to study.
Thanks for the help
Craig
April 23, 2013 at 12:11 pm #37203Brad Dalton
Participant -
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.