WordPress.org

Ready to get started?Download WordPress

Forums

HELP: Assign Custom Header to Pages in Twenty Ten v1.4 (25 posts)

  1. bmoneruiux
    Member
    Posted 2 years ago #

    Hopefully last one for this week lol

    When I was working with WP v3.2 at the beginning of last year, I remember that Twenty Ten made featured images the header of pages they were assigned to. This functionality seems to not work now in v3.4.

    I created a page called about and assigned an image that is the dimension of the header image to the featured image section on the bottom right. I clicked to make sure it was used as a featured image, however when I updated and view the page...nothing has changed.

    Is there something I have to activate or alter in WP v3.4 in order to gain this functionality back?

  2. esmi
    Forum Moderator
    Posted 2 years ago #

    Nope.

  3. bmoneruiux
    Member
    Posted 2 years ago #

    @esmi

    Ok. Care to elaborate on that, or offer a workaround?

    If it was as simple as it used to be, I definitely wouldn't be asking lol. What has changed?

  4. esmi
    Forum Moderator
    Posted 2 years ago #

    Have you checked that you are using an image of the right dimensions - 940px x 198px?

  5. bmoneruiux
    Member
    Posted 2 years ago #

    @esmi

    I've actually altered functions.php so that my images are 980 x 220 as well as unlinking all related 940 x 198 images from the admin panel, so yep they are the size they need to be.

    Is that the only thing that would stop that from happening?

    I am using a custom coded theme, however it's a child of Twenty Ten and I haven't removed any functionality at all.

  6. esmi
    Forum Moderator
    Posted 2 years ago #

    Don't edit the Twenty Ten theme. First create a child theme for your changes.

  7. bmoneruiux
    Member
    Posted 2 years ago #

    @esmi are you reading my posts before responding lol?

    I said I'm creating a child theme lol.

  8. esmi
    Forum Moderator
    Posted 2 years ago #

    You don't "alter" functions.php in a child theme. You add your custom function to the child's functions.php file.

  9. bmoneruiux
    Member
    Posted 2 years ago #

    @esmi

    I told you that I had created a child-theme. With that being said, you don't think I know to create a functions.php file inside of the child-theme? I created a child-theme with all relevant files in the child theme.

    A functions.php file inside of the child-theme folder overrides the function.php in the parent theme. I'm well aware of this.

    So with that being said...what's the next step to figuring this out?

  10. bmoneruiux
    Member
    Posted 2 years ago #

    Ok so to clear up any confusion..

    I'm on WordPress v3.4
    I've created a Child-Theme from Twenty Ten v1.4
    I've overridden Twenty Ten's functions.php with my own located in my child theme
    My site has a static home and blog page
    I've defined a new header image width and height 980px by 220px
    I've unregistered all of the default headers
    I've registered just one new default header which is the header for the home page

    However with all this...when I add a featured image to a Page, it doesn't become the Header of that page and I'm confused as to why. Can someone please help me?

  11. bmoneruiux
    Member
    Posted 2 years ago #

    Here's the code to my child-themes HEADER.PHP file:

    [Code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

  12. bmoneruiux
    Member
    Posted 2 years ago #

    Can anyone help at all?

    I'd rather not use a plug-in if this functionality is easily added to WordPress via a couple lines of PHP.

  13. bmoneruiux
    Member
    Posted 2 years ago #

    In my child-themes Header.PHP file I changed code located on line 71 to:

    if ( is_singular() && current_theme_supports( 'post-thumbnails' ) &&
    to
    if ( is_page() && is_singular() && current_theme_supports( 'post-thumbnails' ) &&

    Yet this is still not working. Can someone please help and tell me what I'm doing wrong?

  14. esmi
    Forum Moderator
    Posted 2 years ago #

    What's the function you used to overwrite the header image dimensions in the child theme?

  15. bmoneruiux
    Member
    Posted 2 years ago #

    @esmi

    define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 980 ) );
    define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 220 ) );
  16. esmi
    Forum Moderator
    Posted 2 years ago #

    That's in the child theme? If so, that's what is causing your problem. You can't DEFINE a constant more than once. Since it's defined in the parent, you cannot re-use DEFINE in the child. You use the filters instead. so something like:

    add_filter( 'twentyten_header_image_width', 'my_header_width' );
    add_filter( 'twentyten_header_image_height', 'my_header_height' );
    function my_header_width($width) {
    	$width = 980;
    	return $width;
    }
    function my_header_height($height) {
    	$height = 220;
    	return $height;
    }

    in the child should work.

  17. bmoneruiux
    Member
    Posted 2 years ago #

    Here's my current functions.php file that's located inside of my child theme:
    functions.php

    And the child-theme header.php file:
    header.php

    I got this technique from the Building Child-Themes with WordPress tutorial from Lynda.com. The person who made the tutorial did this and it worked for him.

    Is this filter versus define thing something that may have possibly changed since the version that he worked on? I'm always curious as to why something works for one person and not another.

    I'll try your suggestion though while you see what could be causing the problem if you have time.

  18. bmoneruiux
    Member
    Posted 2 years ago #

    Ok just tested your filter method and, although it did resize my header like the define...the replacement of the header image still hasn't happened.

    This sucks lol

  19. esmi
    Forum Moderator
    Posted 2 years ago #

    I got this technique from the Building Child-Themes with WordPress tutorial from Lynda.com.

    Sorry but it's really not a good method. If you were running with turn debug on, you'd probably have seen a warning about this.

    I've also spotted one error in your register_default_headers. There's a comma missing after the Home array. You also need to be registering your default headers as part of a custom twentyeleven_setup() in the child theme so that you can add it to the after_setup_theme action.

  20. bmoneruiux
    Member
    Posted 2 years ago #

    Ok so, just to clarify, even if it's the last argument in the register_default_headers array it still needs a comma? I commented out the headers below that just to deal with the one labeled home fo the time being which is why I removed the comment.

    Now as far as Twenty Eleven is concerned, I've lost you lol. What's the significance of me adding that when I'm working with a Twenty Ten child-theme? I wasn't aware I had to do anything with Twenty Eleven as well.

    New child-theme functions.php

  21. esmi
    Forum Moderator
    Posted 2 years ago #

    even if it's the last argument in the register_default_headers array it still needs a comma?

    No. Each entry except the last one needs a comma. Since the first one was missing a comma, that will effectively stop the rest from being parsed.

    I wasn't aware I had to do anything with Twenty Eleven as well.

    Sorry - I seem to have confused you. You don't touch the parent theme. Instead you create a new copy of twentyeleven_setup() in the child theme's functions.php. The parent theme will ensure that this new function is added to the after_setup_theme action.

  22. bmoneruiux
    Member
    Posted 2 years ago #

    Even though I'm creating a Twenty Ten child-theme, I need to copy things from Twenty Elevens functions.php?

    What do I need to copy from there? I'm so very confused lol.

  23. bmoneruiux
    Member
    Posted 2 years ago #

    I've uploaded my child-theme to DropBox in case you want to take a peek at what I'm doing?

    DropBox Zipped Theme

  24. esmi
    Forum Moderator
    Posted 2 years ago #

    Sorry. Sleep happened.

    Even though I'm creating a Twenty Ten child-theme, I need to copy things from Twenty Elevens functions.php?

    Not copy. Create your own customised versions of.

    If there's a function within Twenty eleven that isn't right for your needs, create a custom version - same name, different content. For example, if there a chunk of stuff you don't want within twentyeleven_setup(), create your own twentyeleven_setup() function in the child. copy in the bits that you do want from that function and rewrite (or just plain omit) the bits that you don't like.

  25. nix255
    Member
    Posted 2 years ago #

    I had this exact same problem in a child theme I have set up for twentyten on an older website. It seems the custom code in the functions.php file that worked ok before the upgrade, now doesn't with wordpress 3.4 and the updates.

    To solve this I scrapped the original function that sets the new header size and default header in the child theme's functions.php file. Instead I replaced it with a full copy of the twentyten_setup() function from the twentyten functions.php file and simply changed the references to the header width and size and the path to the new default header image.

    I have kept the unregister functions in the child theme for the original twentyten header images as they seem to work ok.
    This solved the problem of the featured image not working for me.

Topic Closed

This topic has been closed to new replies.

About this Topic