Change slider width in child theme functions.php
-
Deal all,
I am trying to change the width of the featured slider from default 962 to 1170 px. I have read in this forum that it should be done in the childs functions.php file. I have read elsewhere that the function that defines the image-sizes in the parent theme must be filtered out or removed. In either case, my code does not work. I have tried different ways: simply adding the function with the same name (i read that this should override the function in the parent, using add_filter and finally also removing the parents function first, see my current code:
// Remove the default cleanretina_core_functionality function remove_cleanretina_core_functionality() { remove_action('cleanretina_init', 'cleanretina_core_functionality', 20); } // Call 'remove_thematic_actions' (above) during WP initialization add_action('cleanretina_init','remove_cleanretina_core_functionality'); add_action( 'cleanretina_child_init', 'cleanretina_child_core_functionality', 21 ); /** * Adding the core functionality of WordPess. * * @since 1.0 */ function cleanretina_child_core_functionality() { /** * cleanretina_child_add_functionality hook * * Adding other addtional functionality if needed. */ do_action( 'cleanretina_child_add_functionality' ); // Add default posts and comments RSS feed links to head add_theme_support( 'automatic-feed-links' ); // This theme uses Featured Images (also known as post thumbnails) for per-post/per-page. add_theme_support( 'post-thumbnails' ); // Remove WordPress version from header for security concern remove_action( 'wp_head', 'wp_generator' ); // This theme uses wp_nav_menu() in header menu location. register_nav_menu( 'primary', __( 'Primary Menu', 'cleanretina' ) ); // Add Clean Retina custom image sizes add_image_size( 'featured', 700, 290, true); add_image_size( 'featured-medium', 330, 330, true); add_image_size( 'slider', 1170, 390, true); // used on Featured Slider on Homepage Header add_image_size( 'gallery', 330, 230, true); // used to show gallery all images add_image_size( 'test', 300, 400, true); /** * This theme supports custom background color and image */ add_theme_support( 'custom-background' ); // Adding excerpt option box for pages as well add_post_type_support( 'page', 'excerpt' ); } add_action( 'after_setup_theme', 'cleanretina_child_core_functionality', 21 );
What this does is that it indeed removes the parents function (tested: the coded sizes do not show up in the image folder on the server) if I only run the first part. If the ‘cleanretina_child_core_functionality’ is added all the defined image sizes are generated, including the ‘test’ image-size that I added, EXCEPT for the image size ‘slider’ (exactly the one that I want to change according to the increased width of my entire site). The image size ‘slider’ only gets generated from the child theme functions.php if it has the same dimensions as the image size ‘slider’ in the parent themes functions.php file.
I have looked extensively, but could not find the solution. Your help will be greatly appreciated!
Best,
Peter
- The topic ‘Change slider width in child theme functions.php’ is closed to new replies.