A comprehensive guideline on how to use WooCommerce Product Slider filter hooks. We have added the following hooks for developers to extend functionalities. Simply add the following custom code to your current theme’s functions.php file. It’s recommended to keep the code in the functions.php file of your child theme. Because you might lose your customizations if the theme is updated. Keeping the modified codes in your parent theme’s child theme is therefore the best practice.
1) How to provide the plugin access to the Editors
2) How to load the style of Product Slider in the footer section
3) How to change the carousel preloader image
1) How to provide the plugin access to the Editors
If you want to give the plugin access to the Editor role users you can do it easily with the help of the following custom code. If you check the code you can see there is an action hook (sp_wps_shortcodes_ui_permission) available in the plugin which allows you to modify the plugin’s functionality.
// Give access to the Editors function sp_wps_shortcodes_ui_permission_to_editor($capability) { $capability = 'edit_others_pages'; return $capability; } add_filter( 'sp_wps_shortcodes_ui_permission', 'sp_wps_shortcodes_ui_permission_to_editor' );
2) How to load the style of Product Slider in the footer section
If you want to load the testimonial style in the header section you can easily do this with the following custom code. Just copy and paste the following code into your current theme’s functions.php file.
// Style load in footer section add_filter( 'sp_product_slider_style_load_in_header', '__return_false' );
3) How to change the carousel preloader image
The custom code below is about changing the carousel preloader image. With the help of this code, you can upload your custom preloader image for the carousel. If you check the code, you will find there is a filter hook (sp_wps_product_preloader_img) available through which you can do this. You just need to upload the image on your WordPress site and then copy the image link and paste it into the function within the $preloader_url inside the quotation. The preloader image will show up on the front end. Make sure the preloader option is on in the General Settings of the plugin.
// Preloader image change function sp_wps_product_image_preloader_img($preloader_url) { $preloader_url = 'http://product-slider-pro.local/wp-content/uploads/2022/06/pre-loader.gif'; return $preloader_url; } add_filter( 'sp_wps_product_preloader_img', 'sp_wps_product_image_preloader_img' );