WordPress.org

Ready to get started?Download WordPress

Forums

[Theme: Coraline] Changing Header Height, Child Theme Functions.php (3 posts)

  1. sigmaism
    Member
    Posted 2 years ago #

    Hello! I'm very new at messing around with WordPress, not trying to ruin anyone's day here with my questions, but I'm not really sure how to go about this.

    I would like to change the header height. It's 180px but I'd prefer 150.

    This is in functions.php:

    // The height and width of your custom header. You can hook into the theme's own filters to change these values.
    // Add a filter to coraline_header_image_width and coraline_header_image_height to change these values.
    define( 'HEADER_IMAGE_WIDTH', apply_filters( 'coraline_header_image_width', 990 ) );
    define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'coraline_header_image_height', 180 ) );

    I'm trying to understand what a hook or filter are. (Changing the value right there doesn't do anything.) Also, all the documentation I've looked at so far says I need to make a new functions.php in the child theme folder...but when I drop one in, the whole site breaks. Grey screen, can't do nothing. I don't know why. Even when the functions.php file in the child theme directory only contains code regarding the header image, the site just won't load.

    At the very top of the functions.php file is this:

    /** Tell WordPress to run coraline_setup() when the 'after_setup_theme' hook is run. */
    add_action( 'after_setup_theme', 'coraline_setup' );

    if ( ! function_exists( 'coraline_setup' ) ):
    /**
    * Sets up theme defaults and registers support for various WordPress features.
    *
    * To override coraline_setup() in a child theme, add your own coraline_setup to your child theme's
    * functions.php file.

    But again, I don't know how to build the child theme functions.php in such a way that it doesn't break the site.

    Any assistance would be very much appreciated!!! Thanks!

  2. Emil Uzelac
    Theme Review Admin
    Posted 2 years ago #

    In any Theme not just Coraline you can create Child Theme functions.php and overwrite anything you need. Just remember to copy and edit only pieces that you actually need, in your case this will be more than enough: http://pastebin.com/b4pY2uGf

    And change the values from 180 to 150

    define( 'HEADER_IMAGE_WIDTH', apply_filters( 'coraline_header_image_width', 990 ) );
    define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'coraline_header_image_height', 150 ) );

    Upload your /child-theme/functions.php to your server and you're done.

    Cheers,
    Emil

  3. OffCourse2010
    Member
    Posted 1 year ago #

    Hey thanks, I was looking for this.

    I added just those two lines to the child functions.php file and worked great.

    However, I am using this code to present default images but I can't seem to overwrite the default ones.

    //Set some custom header images, add as many as you like
            //%s is a placeholder for your theme directory
            $customHeaders = array (
                    //Image 1
                    'wheel' => array (
                    'url' => '/wp-content/themes/framework/assets/images/headers/carros_em_linha.jpg',
                    'thumbnail_url' => '/wp-content/themes/framework/assets/images/headers/carros_em_linha.jpg',
                    // 'description' => __( 'Car Wheel', 'customisetheme' )
                ),
                    //Image 2
                    'road' => array (
                    'url' => '/wp-content/themes/framework/assets/images/headers/estrada_em_curva.jpg',
                    'thumbnail_url' => '/wp-content/themes/framework/assets/images/headers/estrada_em_curva.jpg',
                    // 'description' => __( 'Open Road', 'customisetheme' )
                ),
                    //Image 3
                    'keys' => array (
                    'url' => '/wp-content/themes/framework/assets/images/headers/estrada.jpg',
                    'thumbnail_url' => '/wp-content/themes/framework/assets/images/headers/estrada.jpg',
                    // 'description' => __( 'Your New Keys', 'customisetheme' )
                ),
         		//Image 4
                    'cars' => array (
                    'url' => '/wp-content/themes/framework/assets/images/headers/parque_de_carros.jpg',
                    'thumbnail_url' => '/wp-content/themes/framework/assets/images/headers/parque_de_carros.jpg',
                    // 'description' => __( 'All My Cars', 'customisetheme' )
                )
            );
            //Register the images with WordPress
            register_default_headers($customHeaders);

    Any idea on how to overwrite these images in the child theme to new ones, with a different size?

Topic Closed

This topic has been closed to new replies.

About this Topic