WordPress.org

Ready to get started?Download WordPress

Forums

Twenty Ten Remove Header Image (20 posts)

  1. seb-syd
    Member
    Posted 4 years ago #

    Hi,
    I want to remove the Twenty Ten image header <?php header_image(); ?> from one of my child themes.
    I want to do this by either using either the :-
    remove_action()
    or
    remove_filter()
    in the child function.php file.
    Is that possible, which to use and what is the code?
    Using wordpress 3 beta 2

  2. MichaelH
    Member
    Posted 4 years ago #

  3. davidcochran
    Member
    Posted 4 years ago #

    I'm trying to do the same. Aaron's post, provided by MichaelH, doesn't remove functions but adds additional features.

    So I sought advice at these three helpful articles:

    No success.

    Admittedly I'm not a pro at this. But it looks to me like the Twentyten setup functions and actions are all wrapped together in a way that makes them hard to pull apart and remove. For now I've made my own copy of Twenty Ten, renamed it (with due credits to the WordPress Team), and have simply removed the actions I don't want.

    But if someone can successfully demonstrate how to do this in a child theme -- i.e., remove just the custom header actions -- I would certainly appreciate the help as well.

  4. wpweaver
    Member
    Posted 4 years ago #

    I just released my child theme Twenty Ten Weaver, and this one was fairly difficult to solve. The only way I could figure out how to do it "right" was to change the header.php code. You can also do it with a filter and set the image height to 0, but that is kind of ugly, and still requires a child theme.

    But the header is included in the #branding section, and can't be removed with just CSS.

    While I was mucking with the header.php anyway, I added the ability to completely replace the Twenty Ten header with your own by adding some code to the header div via a theme control panel.

    And just another plug - if you don't want to build your own child theme (it is now pretty easy to do that with Twenty Ten), my theme Twenty Ten Weaver lets you change a bunch else with Twenty Ten, as well as insert your own CSS or HTML into the header, <HEAD>, and footer, all pretty painlessly. You can save what you've done in an external file for sharing or restoring across upgrades. And if you really need some specialty PHP stuff, you can modify one PHP file to do pretty much whatever you want. I used that capability to replace the header with a sliding photo menu instead.

  5. florushj
    Member
    Posted 4 years ago #

    Does somebody already have an answer to this question? How to simply remove all custom header functionality in twenty ten with the help of the functions file in a child theme?

  6. Tara
    Member
    Posted 4 years ago #

    Go to Aaron's website (see MichaelH respose), and read his response to the last comment where says: "I just wrote a quick post on how to do this. Check it out http://aaron.jorb.in/blog/2010/07/remove-all-default-header-images-in-a-twenty-ten-child-theme/ for the code you’re looking for."

    hope this helps.

  7. florushj
    Member
    Posted 4 years ago #

    It helps, but it's not entirely what I wanted...

    I need the entire custom header functionality removed from twenty ten using the functions.php from my child theme. (So, I need the page etc. removed from the back-end as well.) Can somebody help me some more please?

  8. marthalee
    Member
    Posted 4 years ago #

    I tried to remove the custom header in style.css by setting the #branding img height to 0 in my child theme. This worked before the update of TT 7/23, but then it set the height of all images to 0... it seems that #branding extends the whole length of your page! (Yes, I checked this in the TT theme, it's not just my child theme.) Double annoyance, because I was also trying to use a header image that was narrower and setting the height to less than 198--but it stretched photos in my pages to my new height, even overriding size information included with the photo url!

    I removed the whole business in header.php--not functions.php--by deleting it (you could comment it out, too). I began after the div branding was set up, and ended with an endif just before it code about the site-title.

    For a child theme, don't copy all of TT, just style.css (with REQUIRED note at top) and any other folders you change. If you change header.php you must copy it to your child theme folder or it will be clobbered at next TT update.

    I tried this just last night, seems to work fine so far, but not extensively tested. Hope this helps.

  9. alchymyth
    The Sweeper & Moderator
    Posted 4 years ago #

    adding this function to the functions.php of your child theme allows you to avoid the 'header' option to show in 'appearance':

    function twentyten_setup() {
    /* leave the parts of the code in that you want to get executed;
    for instance, remove the code that does the custom header stuff */
    }

    the code in TwentyTen functions.php will only execute if the 'twentyten_setup()' function is not yet defined in the child theme:
    if ( ! function_exists( 'twentyten_setup' ) ):

  10. florushj
    Member
    Posted 3 years ago #

    @Alchymyth.. what you said works, but shouldn't it be possible to use remove_action etc to create a clean and nice way to start fresh with your child theme?

    if ( !function_exists( 'child_theme_setup' ) ):
    	function child_theme_setup() {
    
    /* put in all the stuff to clean up the twentyten functions and start fresh. e.g. remove custom header functionality, remove widgets etc..  */ 
    
    }
    endif;

    I don't really know how to do this..

  11. eekcm
    Member
    Posted 3 years ago #

    Hi Is it possible to increase the depth of the header. I want to put a larger picture there?

  12. eekcm
    Member
    Posted 3 years ago #

    sorry meant to say the picture size l want to put in is 940x300px so a deeper pik. Tried changing in functions but it wants to crop the image. Any ideas?

  13. govpatel
    Member
    Posted 3 years ago #

    You can use this filter on your child theme functions.php

    add_filter('twentyten_header_image_height','my_header_height');
    add_filter('twentyten_header_image_width','my_header_width');
    function my_header_height($size){
       return 110;
    }
    function my_header_width($size){
       return 350;
    }

    Change the width and height to exact size of your header image.

  14. Gouri
    Member
    Posted 3 years ago #

    Go to your header.php in the twenty ten template file and look for the following code:
    <img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />

    Comment it out so that it looks like this:
    <!-- <img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />-->

  15. govpatel
    Member
    Posted 3 years ago #

    Go to your header.php in the twenty ten template file and look for the following code:

    When you make any change in core twenty ten theme file next time you update the file will be over written so create a child theme and copy the file in child theme and make the change there.

  16. zeaks
    Member
    Posted 3 years ago #

    I was looking for how to do this as well, using the code from above, I added this to my child theme and it worked. Haven't noticed any issues so far.

    function twentyten_setup() {
    /* leave the parts of the code in that you want to get executed;
    for instance, remove the code that does the custom header stuff */
    }
    add_custom_background();
    add_theme_support( 'post-thumbnails' );
  17. govpatel
    Member
    Posted 3 years ago #

    As long as you make your changes in child theme you will not have any problem as twenty ten is the default theme is over written with every update.

  18. davidcasey
    Member
    Posted 3 years ago #

    I removed the header image as an option in the interface by doing the following:

    In header.php, I wrapped two lines of code around the header code

    if ( get_header_image() ) :
    endif;

    Now, go to: Admin > Appearance > Header > Remove Header Image

    Your header image and markup will now be gone, yet re-enabled should you select a new image.

    So, to clarify, the header code in header.php should look like this:

    <?php
    if ( get_header_image() ) :
      // Check if this is a post or page, if it has a thumbnail, and if it's a big one
      if ( is_singular() &&
          has_post_thumbnail( $post->ID ) &&
          ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' ) ) &&
          $image[1] >= HEADER_IMAGE_WIDTH ) :
        // Houston, we have a new header image!
        echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' );
      else : ?>
        <img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
      <?php endif; ?>
    <?php endif; ?>
  19. mtwelve
    Member
    Posted 3 years ago #

    this would obviously depend on what else you were doing in #branding but this line in your style.css works

    #branding img {
    	display: none;
    	}

    and if you go to the menu and select "remove image" the browser wont load anything there... not sure if it will validate though.

    or this in the functions.php; it comes from: http://aaron.jorb.in/blog/2010/07/remove-all-default-header-images-in-a-twenty-ten-child-theme/

    function jorbin_remove_twenty_ten_headers(){
        unregister_default_headers( array(
            'berries',
            'cherryblossom',
            'concave',
            'fern',
            'forestfloor',
            'inkwell',
            'path' ,
            'sunset')
        );
    }
    
    add_action( 'after_setup_theme', 'jorbin_remove_twenty_ten_headers', 11 );
  20. thecoup
    Member
    Posted 3 years ago #

    As Zeaks said above, you can call the setup function in your child theme to override twentyten's options. Add back the pieces you want to keep. Zeaks example will work, but you will lose the Menu and the ability to an editor style sheet.

    /**
     * Remove Header options from Appearance Settings
     *
     */
    function twentyten_setup() {
    	/* calling this function overrides the one in twentyten */
    	/* add back the pieces you want to keep below.  */
    }
    
    	// This theme styles the visual editor with editor-style.css to match the theme style.
    	add_editor_style();
    
    	// This theme uses post thumbnails
    	add_theme_support( 'post-thumbnails' );
    
    	// Add default posts and comments RSS feed links to head
    	add_theme_support( 'automatic-feed-links' );
    
    	// This theme uses wp_nav_menu() in one location.
    	register_nav_menus( array(
    		'primary' => __( 'Primary Navigation', 'twentyten' ),
    	) );
    
    	// This theme allows users to set a custom background
    	add_custom_background();

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags