Forums

twentyten child function.php filter header image height (11 posts)

  1. nrodger
    Member
    Posted 1 year ago #

    my function.php file code.

    Thanks,

    <?php
    
    function twentyten_setup() {
    
    }
    	define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 940 ) );
    	define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 120 ) );
    
    ?>
  2. t-p
    Member
    Posted 1 year ago #

    what's your question?

  3. nrodger
    Member
    Posted 1 year ago #

    Thanks,
    When I pushed submit post, part of the post disappeared and I resent, but now it isn't showing.
    Here goes:
    I created a child them in Twentyten. I wanted to change the header height only. I created the function.php file within the child theme after searching and trying many suggestions adding a filter as shown in the above post of mine. The image is not changing size but remaining as it's default height.

    Could you please suggest what I am doing wrong.

    Thanks,
    Nancy

  4. t-p
    Member
    Posted 1 year ago #

    is your folder /wp-content/upload/ writable?

  5. nrodger
    Member
    Posted 1 year ago #

    Yes it is read, write, execute by owner.

  6. t-p
    Member
    Posted 1 year ago #

    Is your image exactly of the size 940X120? make sure you have uploaded it and is in the right folder.

  7. nrodger
    Member
    Posted 1 year ago #

    The image file was uploaded via the header image uploader within wordpress. It is the exact size I want. 940px x 120px
    When I change the size of the image via the header image size filter on the twenty ten function.php (as opposed to my function.php I created for the child theme) the image shows the correct size.

    Would the image need to live somewhere else other then the uploads directory?

    I am wondering if there is something wrong with my php code. I am not savvy in php. The code is up above in my first post.

    Thanks

  8. t-p
    Member
    Posted 1 year ago #

    You should be changing the size in the child theme. Otherwise it defeats the purpose of having a child theme.

    The filters look OK. But there may be problem with your child functions.php

  9. Digital Raindrops
    Member
    Posted 1 year ago #

    With a child theme you do not do anything in the parent folder, all changes and additions are done in the child themes folder.

    If you have not done this yet then create a file in your child themes folder called functions.php the file starts with the php tag <?php

    Then you need a function in the file that runs after the theme has been setup, with the after_setup_theme action hook

    <?php
    
    add_action( 'after_setup_theme', 'child_theme_setup' );
    
    if ( !function_exists( 'child_theme_setup' ) ):
    function child_theme_setup() {
    	define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 120 ) );
    }
    endif;

    That's it done!

    Need a practical tutorial using a Twenty Ten Child Theme?

    I have written one that starts here:

    HTH

    David

  10. nrodger
    Member
    Posted 1 year ago #

    Thanks for you help.
    I found a solution. I replaced the default header image and it's size in the child's functions.php and uploaded the new image to an image directory in the child's theme directory. I may have been missing that piece of the puzzle that you hit on.

    I got help from this post:

    http://wpti.ps/functions/replace-default-header-image-twenty-ten-theme/

    Thanks for your time and patience!!!

    Nancy

  11. lightrail
    Member
    Posted 1 year ago #

    Very helpful! Thanks, Nancy -- that post you linked to was exactly what I needed.

Topic Closed

This topic has been closed to new replies.

About this Topic