The following is a simple snippet which describes how to replace the sliders default navigation arrows with icons. The method detailed below will also make it possible to use an image or whatever you want as navigation for your slider.
Where to copy/paste the code above code? I strongly recommend that you create a child theme. Download a start-up child theme here.
Everything you need to know about child theme with Customizr here.
PHP code
Is there a filter hook available to do that? Yes, there are actually two hooks.
In class-content-slider, you will find those lines of codes :
<?php if ( count($slides) > 1 ) : ?> <a class="left carousel-control" href="#customizr-slider" data-slide="prev"> <?php echo apply_filters( 'tc_slide_left_control', '‹' ) ?> </a> <a class="right carousel-control" href="#customizr-slider" data-slide="next"> <?php echo apply_filters( 'tc_slide_right_control', '›' ) ?> </a> <?php endif; ?>
We are going to replace the default values of the filters : ‘tc_slide_left_control’ and ‘tc_slide_right_control’ by a custom markup with a callback function.
Here ‘s the PHP code to copy in your functions.php :
add_filter('tc_slide_left_control' , 'my_custom_buttons'); add_filter('tc_slide_right_control' , 'my_custom_buttons'); function my_custom_buttons() { printf('<span class="slider-button-%1$s"></span>', ( 'tc_slide_left_control' == current_filter() ) ? 'left' : 'right' ); }
CSS Code
In this example, I use icons from the Entypo font-icon included in the theme, but you can use an image background if needed.
Here’s the code to copy in your style.css file or in the Custom CSS section.
.slider-button-left:before, .slider-button-right:before { font-family: 'entypo'; speak: none; font-weight: normal; font-variant: normal; text-transform: none; line-height: 0; -webkit-font-smoothing: antialiased; } .slider-button-left:before { content:'\E759'; float: left; } .slider-button-right:before { content:'\E75A'; float: right; }
The good thing about using those icons is that they inherit the hover pseudo-class properties of the parent link (carousel-control), meaning that you don’t have to worry about the hovering color of those custom navigation icons, they will use the main color of your skin.
I hope this will be useful and your feedbacks or implementation examples are always welcome!
24 thoughts on “Customizing the slider navigation arrows”
This snippet does not work for me in version 3.4+
The workaround is to use `return sprintf`in place of `printf“
as below:
This Snippet didnt work for me.
It showed the Icons but they just had no fucntion in them. I could not click on them and make the slider … well slide.
This is how i solved it. Maybe someone has the same issue.
after that set the position of the arrows via css
Oh my URL got removed from the code here is the function again
and the same with right
Hi ! I’d like to change the color of the bottom arrow (the one allowing to come back to the top of the page) do you have an idea of what is needed to change ?
Thanks,
Marie
Nevermind, you can delete my comments, I found the (hidden) solution in another forum 😀
thanks nicolas…worked perfectly!
but i’m not able to see the slider controls in the mobile. any CSS handlers for this? thanks!
Slider controls are hidden by default on mobile since the theme supports the swipe with fingers features on those devices.
If you need to reactivate the controls on mobile devices, you’ll need to add a code snippet into your functions.php file.
Hope this helps !
found it. change opacity to 1 = visible, 0 = hidden and 0.1 upto 0.9
`.tc-slider-controls {
opacity: 1;
}`
Great, thanks for the update and I’m glad you found it !
thanks nicolas, i tried addin this to my child theme and it didn’t work. any clues? thanks again!
`.carousel-inner > .active,
.carousel-inner > .next,
.carousel-inner > .prev {
display: block;
}`
hi, is there a code snippet, or a way to make these arrows always visible and not become visible on a ‘mouse-over’ on the carousel? it’d help someone know at a glance that there are more images to come.
you can see my work-in-progress site at bent.co.in/wordpress/
thanks, kuldeep
Hi, they are by default set not visible with a simple CSS line of code. You can easily add your custom css to make them visible.
Hope this will help!
hi,i want to remove Bullets caption Carousel in bootstrap but i want to have writes without bulleted contorol…can you help me?? 🙂
Hello Nicolas, okay? How can I decrease the height of the slider?
Great, it worked perfectly!
I’m super happy about the theme and I’m going to buy the extension for more featured pages.
Until three days ago I had never seen a Wordpress dashboard and now I have a more than decent website.
There is still a lot of work to do though, so expect few more questions!
🙂
I am glad it helped Andrea,
Enjoy the Customizr theme!
Hi Nicolas, how can I simply change the color of the arrows? With some pictures the default grey kind of disappears.
Many thanks for this an for the beautiful theme!
Regards.
Hi Andrea,
The color of the carousel arrows is controlled by the following CSS code :
When i paste the code into functions.php the arrows disappear. Do you know why?
Hello,
How can I replace the previous and next button with hover dots that show the corresponding slide on click?
So if they have added 3 photos to the slider I show three circles across the bottom of the viewer. If they click the 2nd one it jumps to the second. If they click the 3rd it jumps to the third etc.
The cycling of photos still happens as is normally set..
If they add more photos then I display more circles to click. n circles for n numbers of photos.
Thanks!
Hi Christen,
This feature is not implemented yet in the theme.
those are interesting links about adding bullets / paging to the Twitter Bootstrap carousel :
https://github.com/twbs/bootstrap/issues/1993
http://stackoverflow.com/questions/12271827/bootstrap-carousel-add-pagination-dots-to-bottom
I might write a snippet about this soon.
Cheers
According to this post on Stackoverflow (https://stackoverflow.com/questions/20649142/adding-bullets-to-a-slider-on-customizr-wordpress-theme), Bootstrap 3.x will include the pagination bullets for the slider. Is Customizr based on Bootstrap 2? If so, is there an upgrade roadmap to 3.x?
I would like to be able to just have the pagination options for the slides with the option to include the little arrows.
Thanks for a great theme!
Hi Chad , yes Customizr is based on Bootstrap v2.x.
I might come with a plugin to make the upgrade to 3.x. I can’t really give a precise roadmap about this implementation though.
Thanks