WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] different headers (by page template) in twenty eleven child theme (8 posts)

  1. Marlene
    Member
    Posted 1 year ago #

    Hi all,
    I want to know if its possible to have a different size of the header image in twenty elevent theme, for example:
    Template one:header image 980 x350:
    (Important: I have changed already the default size for the template:

    function my_header_image_height($height) {
    	return 350;
    }
    add_filter( 'twentyeleven_header_image_height', 'my_header_image_height');
    
    function my_header_image_width($width) {
    	return 980;
    }
    add_filter( 'twentyeleven_header_image_width', 'my_header_image_width');
    )
    Template two: header image 980x100.
    Here is the problem because it gets the values of template one (setted up by php code in functions.php for my child theme.
    I'm not a developer so I guess there is a php function to do this, any help?
    thank you in advance

  2. Marlene
    Member
    Posted 1 year ago #

    any help on this?? I would like to know how to do it!!

  3. paulwpxp
    Font hero
    Posted 1 year ago #

    2011's header-image already has flexible-height built in, and the header-image itself depends on the featured image of that post/page being display.

    So you do not need to do anything extra with any php or css. All you need to do is assign a featured image for each post/page and make sure its width is equal or higher than 1000px.

    Making the header-image smaller than 1000px (in width) doesn't make sense anyway, because the theme's width is 1000px in normal situation, so 1000px is it.

  4. Marlene
    Member
    Posted 1 year ago #

    thank you Paulwpxp but this doesn't answer my question, as you can see inthe code, the height and width are managed by code:

    function my_header_image_height($height) {
    	return 350;
    }
    add_filter( 'twentyeleven_header_image_height', 'my_header_image_height');

    If the flexible-height is built how can I change this code?, if I add a different high image, the code resize the image...
    the change to 980px is because the design is built like that, but in any case the widht isn't an issue...

  5. paulwpxp
    Font hero
    Posted 1 year ago #

    So you do not need to do anything extra with any php or css. All you need to do is assign a featured image for each post/page and make sure its width is equal or higher than 1000px.

  6. Marlene
    Member
    Posted 1 year ago #

    sorry, english is not my mother tounge, so maybe I'm not explaingin very good my issue :S
    I have setted up the featured image, but let say that at the subpages I want to have a smaller image (only height) than the main pages, the code is setted up for the images to have always the same height and width, so if my image is smaller, it stretches the image until the height and width is the same in the code.

  7. paulwpxp
    Font hero
    Posted 1 year ago #

    Suppose you have a site structure like this

    — Fruit
    ——— Apple
    ——— Orange

    On the Fruit page, you want a bigger header image than Apple and Orange which are subpages, am I correct ? If that's so, suppose the bigger size is 1000x200, and the smaller size for subpages is 1000x150, then you would prepare these images.

    featured-image-fruit.jpg  | w=1000px, h=200px
    featured-image-apple.jpg  | w=1000px, h=150px
    featured-image-orange.jpg | w=1000px, h=150px

    When you edit each page, just upload AND assign each image as featured, it will be used as custom-header automatically and will be displayed as is.

    Here is the proof, it's from my local using WP3.5.1 with 2011 that comes with it.

    Parent page = 1000x200
    http://i.imgur.com/uQV0zfJ.png

    Sub page = 1000x150
    http://i.imgur.com/gMCG81V.png

  8. Marlene
    Member
    Posted 1 year ago #

    Well... now it works!!, I've been searching this for weeks!, maybe they fixed in the latest update but this didn't work before...
    Thank you Paulwpxp! :D

Topic Closed

This topic has been closed to new replies.

About this Topic