• 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

Viewing 4 replies - 16 through 19 (of 19 total)
  • 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.

    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; ?>

    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: https://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 );

    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();
Viewing 4 replies - 16 through 19 (of 19 total)
  • The topic ‘Twenty Ten Remove Header Image’ is closed to new replies.