Overrite parent functions using child functions

Question

So I’ve tried a few different ways to override a method inside the parent theme and I’m not having much luck at all.

So here is the structure:

themes/
– wp-starter
— custom_header.php
– wp-starter-child
— custom_header.php

I have a method inside the parent custom_header.php as shown below:

function wp_bootstrap_starter_custom_header_setup() {
    add_theme_support( 'custom-header', apply_filters( 'wp_bootstrap_starter_custom_header_args', array(
        'default-image'          => '',
        'default-text-color'     => 'fff',
        'width'                  => 1000,
        'height'                 => 250,
        'flex-height'            => true,
        'wp-head-callback'       => 'wp_bootstrap_starter_header_style',
    ) ) );
}
add_action( 'after_setup_theme', 'wp_bootstrap_starter_custom_header_setup' );

Now.. I want to be able to call that method inside my child custom_header.php and override the width and height.

Here are a few attempts:

Added priority to action (Didn’t work):

function wp_bootstrap_starter_custom_header_setup() {
    add_theme_support( 'custom-header', apply_filters( 'wp_bootstrap_starter_custom_header_args', array(
        'default-image'          => '',
        'default-text-color'     => 'fff',
        'width'                  => 1000,
        'height'                 => 500,
        'flex-height'            => true,
        'wp-head-callback'       => 'wp_bootstrap_starter_header_style',
    ) ) );
}
add_action('after_setup_theme', 'wp_bootstrap_starter_custom_header_setup', 20);

Renamed the method and added priority (Didn’t work):

function wp_bootstrap_starter_custom_header_setup() {
    add_theme_support( 'custom-header', apply_filters( 'wp_bootstrap_starter_custom_header_args', array(
        'default-image'          => '',
        'default-text-color'     => 'fff',
        'width'                  => 1000,
        'height'                 => 500,
        'flex-height'            => true,
        'wp-head-callback'       => 'wp_bootstrap_starter_header_style',
    ) ) );
}
add_action('after_setup_theme', 'wp_bootstrap_starter_custom_header_setup', 20);

Added an init action call with priority (Didn’t work):

function wp_bootstrap_starter_custom_header_setup() {
    add_theme_support( 'custom-header', apply_filters( 'wp_bootstrap_starter_custom_header_args', array(
        'default-image'          => '',
        'default-text-color'     => 'fff',
        'width'                  => 1000,
        'height'                 => 500,
        'flex-height'            => true,
        'wp-head-callback'       => 'wp_bootstrap_starter_header_style',
    ) ) );
}
add_action('after_setup_theme', 'wp_bootstrap_starter_custom_header_setup' );
add_action('init', 'wp_bootstrap_starter_custom_header_setup', 15);

So I’ve tried doing remove_action('after_setup_theme', 'wp_bootstrap_starter_custom_header_setup'); with no results.

0
, , , Sem 8 months 0 Answers 94 views 0

Leave an answer