Override Function for Image Sizes in Child Theme
-
function mh_themes_setup() { global $content_width; if (!isset($content_width)) { $content_width = 620; } $header = array( 'default-image' => '', 'width' => 300, 'height' => 100, 'flex-width' => true, 'flex-height' => true, 'header-text' => false ); add_theme_support('custom-header', $header); load_theme_textdomain('mh', get_template_directory() . '/languages'); add_theme_support('automatic-feed-links'); add_theme_support('custom-background'); add_theme_support('post-thumbnails'); add_image_size('content', 620, 264, true); add_image_size('loop', 174, 131, true); add_image_size('cp_small', 70, 53, true); add_editor_style(); register_nav_menu('main_nav', __('Main Navigation', 'mh')); } add_action('after_setup_theme', 'mh_themes_setup');I want to change the size of the thumbnails in the above code found in the parent theme’s functions.php. I created a child theme w a new functions.php & placed the following code in it so that future parent theme updates wont wipe out my changes but nothing I’ve tried seems to be overriding the above code. Can someone tell me why this code doesn’t work?
// replace parent function function irs_themes_setup() { global $content_width; if (!isset($content_width)) { $content_width = 620; } $header = array( 'default-image' => '', 'width' => 300, 'height' => 100, 'flex-width' => true, 'flex-height' => true, 'header-text' => false ); add_theme_support('custom-header', $header); load_theme_textdomain('mh', get_template_directory() . '/languages'); add_theme_support('automatic-feed-links'); add_theme_support('custom-background'); add_theme_support('post-thumbnails'); add_image_size('content', 620, 332, true); add_image_size('loop', 245, 131, true); add_image_size('cp_small', 99, 53, true); add_editor_style(); register_nav_menu('main_nav', __('Main Navigation', 'mh')); } function remove_mh_themes_setup () { remove_action('after_setup_theme', 'mh_themes_setup'); add_action( 'after_setup_theme', 'irs_themes_setup' ); } add_action( 'after_setup_theme', 'remove_mh_themes_setup' );Maybe I’m overlooking something.. I called myself unhooking the parent functions.php code in the child theme but it seems like the parent is still overriding the child because my thumbnails aren’t the size I changed them to. I read that since the child’s functions.php loads first, the parent is supposed to override it but am i supposed to add some kinda priorities to make the code in the child theme load last? If this cant be done how should I go about changing my thumbnail sizes without touching the parent functions.php?
The topic ‘Override Function for Image Sizes in Child Theme’ is closed to new replies.
